Form changed to contect to database?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Rob (SA)
    Lieutenant Colonel

    • Nov 2006
    • 586

    #16
    Re: Form changed to contect to database?

    Hi Watdaflip,

    Thanks again for your support. It is most appreciated.

    Herewith the details requested.

    <?php
    $MySQLhost="localhost";
    $MySQLusername="r0berth";
    $MySQLpassword="f0undat10n";
    $MySQLdatabase="eghfya_members";
    $dbconnect = mysql_connect($MySQLhost,$MySQLusername,$MySQLpass word)
    or die ("Could not connect to mysql because ".mysql_error());
    mysql_select_db($MySQLdatabase)
    or die ("Could not select database because ".mysql_error());
    $select = mysql_query("SELECT * FROM MEMBERS", $dbconnect);
    echo '
    <table>
    <tr>
    <td>Gender</td>
    <td>Name</td>
    <td>Surname</td>
    <td>Country</td>
    <td>Date_of_Birth</td>
    <td>Identity_No</td>
    <td>P_O_Box</td>
    <td>Suburb</td>
    <td>Postal_Code</td>
    <td>Relationship</td>
    <td>Language</td>
    <td>Gaurdians_Name</td>
    <td>Gaurdians_Surname</td>
    <td>Cell_Phone</td>
    <td>Home_phone</td>
    <td>Work_phone</td>
    <td>Fax</td>
    <td>email</td>
    <td>Division</td>
    <td>Home_Club</td>
    <td>Handicap</td>
    <td>School</td>
    <td>Grade</td>
    <td>Type</td>
    <td>Membership</td>
    <td>Rules</td>
    </tr>';
    while($row = mysql_fetch_assoc($select))
    {
    echo '
    <tr>
    <td>'.$row['Gender'].'</td>
    <td>'.$row['Name'].'</td>
    <td>'.$row['Surname'].'</td>
    <td>'.$row['Country'].'</td>
    <td>'.$row['Date_of_Birth'].'</td>
    <td>'.$row['Identity_No'].'</td>
    <td>'.$row['P_O_Box'].'</td>
    <td>'.$row['Suburb'].'</td>
    <td>'.$row['Postal_Code'].'</td>
    <td>'.$row['Relationship'].'</td>
    <td>'.$row['Language'].'</td>
    <td>'.$row['Gaurdians_Name'].'</td>
    <td>'.$row['Gaurdians_Surname'].'</td>
    <td>'.$row['Cell_Phone'].'</td>
    <td>'.$row['Home_phone'].'</td>
    <td>'.$row['Work_phone'].'</td>
    <td>'.$row['Fax'].'</td>
    <td>'.$row['email'].'</td>
    <td>'.$row['Division'].'</td>
    <td>'.$row['Home_Club'].'</td>
    <td>'.$row['Handicap'].'</td>
    <td>'.$row['School'].'</td>
    <td>'.$row['Grade'].'</td>
    <td>'.$row['Type'].'</td>
    <td>'.$row['Membership'].'</td>
    <td>'.$row['Rules'].'</td>
    </tr>';
    }
    echo '</table>';
    $Gender=$_GET['Gender:'];
    $Name=$_GET['Name'];
    $Surname=$_GET['Surname:'];
    $Country=$_GET['Country:'];
    $Date_of_Birth=$_GET['Date_of_Birth:'];
    $Identity_No=$_GET['Identity_No'];
    $P_O_Box=$_GET['P_O_Box'];
    $Postal_Code=$_GET['Postal_Code'];
    $Suburb=$_GET['Suburb'];
    $Relationship=$_GET['Relationship'];
    $Language=$_GET['Language'];
    $Gaurdians_Name=$_GET['Gaurdians_Name'];
    $Gaurdians_Surname=$_GET['Gaurdians_Surname'];
    $Cell_Phone=$_GET['Cell_Phone'];
    $Home_phone=$_GET['Home_phone'];
    $Work_phone=$_GET['Work_phone'];
    $Fax=$_GET['Fax'];
    $email=$_GET['email'];
    $Division=$_GET['Division'];
    $Home_Club=$_GET['Home_Club'];
    $School=$_GET['School'];
    $Grade=$_GET['Grade'];
    $Type=$_GET['Type'];
    $Membership=$_GET['Membership'];
    $Rules=$_GET['Rules'];
    $Rules=$_GET['Handicap'];




    $query = mysql_query("INSERT INTO MEMBERS VALUES ('', '$Gender', '$Name', '$Surname', '$Country', '$Date_of_Birth', '$Identity_No', '$P_O_Box', '$Postal_Code', '$Suburb', '$Relationship', '$Language', '$Gaurdians_Name', '$Gaurdians_Surname', '$Cell_Phone', '$Home_phone', '$Work_phone', '$email', '$Division', '$Handicap', '$School', '$Grade', '$Type', '$Membership', '$Home_Club', '$Fax', '$Rules')", $dbconnect);
    echo "Form submitted";
    ?>
    Kind Regards
    Rob
    www.gnjgf.co.za
    www.oryan-projects.com

    Comment

    • Watdaflip
      Major General

      • Sep 2005
      • 2116

      #17
      Re: Form changed to contect to database?

      Ok, you need to have the database connection at the top (everything before the line that starts with $select) and everything after $Gender=$_GET['Gender']; included in the script that is sending the email.

      Also I don't know if you are using a get or post method with your form, but you may need to change all instances of _GET to _POST, if you give me a link to the form I will let you know.

      And the code that displays the contents of the database (which looks like you did correctly) would probably be best to have on its own page (which I guess it will be when you remove the insert query.. but make sure you leave the database connection for both)

      Register/Login Script
      Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

      Comment

      • Rob (SA)
        Lieutenant Colonel

        • Nov 2006
        • 586

        #18
        Re: Form changed to contect to database?

        Hi Watdaflip,

        Thanks again.

        Slowly but surely I am making progress.

        Please inform me as to how I get the section after $Gender . . . inccluded in the script that is sending the mail?

        I would like to create a totally new page to present the results of the membership. That page could be called GNJGFMem. This page is not yet created.
        Kind Regards
        Rob
        www.gnjgf.co.za
        www.oryan-projects.com

        Comment

        • Watdaflip
          Major General

          • Sep 2005
          • 2116

          #19
          Re: Form changed to contect to database?

          I wasn't sure what you were saying so I copy and modified it to be two different scritps. The first of what you need to add to your email script. If you created that using the form wizard you will have to open the php processing file for that form and insert the code there (afer the mail() function).

          The second is for the display, you can just copy and paste that into a html box and publish.

          PHP Code:
          <?php
          $MySQLhost
          ="localhost"
          $MySQLusername="r0berth"
          $MySQLpassword="f0undat10n"
          $MySQLdatabase="eghfya_members"
          $dbconnect mysql_connect($MySQLhost,$MySQLusername,$MySQLpass  word
          or die (
          "Could not connect to mysql because ".mysql_error()); 
          mysql_select_db($MySQLdatabase
          or die (
          "Could not select database because ".mysql_error());

          $Gender=$_GET['Gender:']; 
          $Name=$_GET['Name']; 
          $Surname=$_GET['Surname:']; 
          $Country=$_GET['Country:']; 
          $Date_of_Birth=$_GET['Date_of_Birth:']; 
          $Identity_No=$_GET['Identity_No']; 
          $P_O_Box=$_GET['P_O_Box']; 
          $Postal_Code=$_GET['Postal_Code']; 
          $Suburb=$_GET['Suburb']; 
          $Relationship=$_GET['Relationship']; 
          $Language=$_GET['Language']; 
          $Gaurdians_Name=$_GET['Gaurdians_Name']; 
          $Gaurdians_Surname=$_GET['Gaurdians_Surname']; 
          $Cell_Phone=$_GET['Cell_Phone']; 
          $Home_phone=$_GET['Home_phone']; 
          $Work_phone=$_GET['Work_phone']; 
          $Fax=$_GET['Fax']; 
          $email=$_GET['email'];
          $Division=$_GET['Division'];
          $Home_Club=$_GET['Home_Club'];
          $School=$_GET['School'];
          $Grade=$_GET['Grade'];
          $Type=$_GET['Type'];
          $Membership=$_GET['Membership'];
          $Rules=$_GET['Rules'];
          $Rules=$_GET['Handicap'];
           
          $query mysql_query("INSERT INTO MEMBERS VALUES ('', '$Gender', '$Name', '$Surname', '$Country', '$Date_of_Birth', '$Identity_No', '$P_O_Box', '$Postal_Code', '$Suburb', '$Relationship', '$Language', '$Gaurdians_Name', '$Gaurdians_Surname', '$Cell_Phone', '$Home_phone', '$Work_phone', '$email', '$Division', '$Handicap', '$School', '$Grade', '$Type', '$Membership', '$Home_Club', '$Fax', '$Rules')"$dbconnect);

          ?>
          PHP Code:
          <?php
          $MySQLhost
          ="localhost"
          $MySQLusername="r0berth"
          $MySQLpassword="f0undat10n"
          $MySQLdatabase="eghfya_members"
          $dbconnect mysql_connect($MySQLhost,$MySQLusername,$MySQLpass  word
          or die (
          "Could not connect to mysql because ".mysql_error()); 
          mysql_select_db($MySQLdatabase
          or die (
          "Could not select database because ".mysql_error());
          $select mysql_query("SELECT * FROM MEMBERS"$dbconnect); 
          echo 
          '
          <table>
          <tr>
          <td>Gender</td>
          <td>Name</td>
          <td>Surname</td>
          <td>Country</td>
          <td>Date_of_Birth</td>
          <td>Identity_No</td>
          <td>P_O_Box</td>
          <td>Suburb</td>
          <td>Postal_Code</td>
          <td>Relationship</td>
          <td>Language</td>
          <td>Gaurdians_Name</td>
          <td>Gaurdians_Surname</td>
          <td>Cell_Phone</td>
          <td>Home_phone</td>
          <td>Work_phone</td>
          <td>Fax</td>
          <td>email</td>
          <td>Division</td>
          <td>Home_Club</td>
          <td>Handicap</td>
          <td>School</td>
          <td>Grade</td>
          <td>Type</td>
          <td>Membership</td>
          <td>Rules</td>
          </tr>'
          ;
          while(
          $row mysql_fetch_assoc($select))
          {
          echo 
          '
          <tr>
          <td>'
          .$row['Gender'].'</td>
          <td>'
          .$row['Name'].'</td>
          <td>'
          .$row['Surname'].'</td>
          <td>'
          .$row['Country'].'</td>
          <td>'
          .$row['Date_of_Birth'].'</td>
          <td>'
          .$row['Identity_No'].'</td>
          <td>'
          .$row['P_O_Box'].'</td>
          <td>'
          .$row['Suburb'].'</td>
          <td>'
          .$row['Postal_Code'].'</td>
          <td>'
          .$row['Relationship'].'</td>
          <td>'
          .$row['Language'].'</td>
          <td>'
          .$row['Gaurdians_Name'].'</td>
          <td>'
          .$row['Gaurdians_Surname'].'</td>
          <td>'
          .$row['Cell_Phone'].'</td>
          <td>'
          .$row['Home_phone'].'</td>
          <td>'
          .$row['Work_phone'].'</td>
          <td>'
          .$row['Fax'].'</td>
          <td>'
          .$row['email'].'</td>
          <td>'
          .$row['Division'].'</td>
          <td>'
          .$row['Home_Club'].'</td>
          <td>'
          .$row['Handicap'].'</td>
          <td>'
          .$row['School'].'</td>
          <td>'
          .$row['Grade'].'</td>
          <td>'
          .$row['Type'].'</td>
          <td>'
          .$row['Membership'].'</td>
          <td>'
          .$row['Rules'].'</td>
          </tr>'
          ;
          }
          echo 
          '</table>';
          ?>

          Register/Login Script
          Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

          Comment

          • Rob (SA)
            Lieutenant Colonel

            • Nov 2006
            • 586

            #20
            Re: Form changed to contect to database?

            Hi Watdaflip,

            Thanks again for all your time.

            I have psoted the second file (PHP) into my page - anywhere as suggested.

            I have looked fro the "mail ()" function to no avail and in my search have found the following:

            Parents and supporters</b> are encouraged to enrol here entiling them to voice and vote in the affairs of the Division</font></div>
            <div id="bv_" style="position:absolute;left:0px;top:1px;width:64 5px;height:526px;z-index:83" align="left">
            <form name="application" method="POST" action="<? echo($_SERVER['PHP_SELF']);?>" enctype="multipart/form-data" id="" onsubmit="return Validateapplication(this)"

            >
            <div id="bv_Text11" style="position:absolute;left:89px;top:270px;width :68px;height:14px;z-index:0" align="center">
            <font style="font-size:11px" color="#7F7F7F" face="Arial">YYYYMMDD</font></div>


            My thinking is that it could be somewhere here that the first form should be installed.

            The email form uses Naval's form which uses a built in php form processor so form me you can see it is pretty awkward to find.
            Kind Regards
            Rob
            www.gnjgf.co.za
            www.oryan-projects.com

            Comment

            • Watdaflip
              Major General

              • Sep 2005
              • 2116

              #21
              Re: Form changed to contect to database?

              The action of the form is the file itself, so the code should be somewhere on the page. If you open it in the file manager or download it to your comptuer and open it in notepad, it should have the code to send the email. Find where that is and that should help you locate the code in the bv file.

              Register/Login Script
              Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

              Comment

              • Rob (SA)
                Lieutenant Colonel

                • Nov 2006
                • 586

                #22
                Re: Form changed to contect to database?

                Hi Watdaflip,

                I am sorry if I cant explain myself in design terms and I am sure we could be further if I could have. Thanks for your patience.

                I have published the page at www.gnjgf.co.za/application.php and then veiwed source to look for the line you are indicating.

                Is this the wrong method?

                If it is I am not sure to the method you are proposing.

                I look forward to your reply
                Kind Regards
                Rob
                www.gnjgf.co.za
                www.oryan-projects.com

                Comment

                • Watdaflip
                  Major General

                  • Sep 2005
                  • 2116

                  #23
                  Re: Form changed to contect to database?

                  Are you viewing the source in your browser? If so it will process and remove all of the php code and replace it with output if there is any. In order to see the php code you would either need to download it via ftp and open it, go to your file manager and edit the file to see all the html and php code, or to find it whereever it may have been entered in BV.

                  Register/Login Script
                  Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

                  Comment

                  • Rob (SA)
                    Lieutenant Colonel

                    • Nov 2006
                    • 586

                    #24
                    Re: Form changed to contect to database?

                    Hi Watdaflip,

                    I have downloaded the .php and veiwed opening with notebook to find something like this

                    $message .= "\nThe following file have been uploaded:\n";
                    for ($i = 0; $i < count($upload_SrcName); $i++)
                    {
                    $message .= $upload_SrcName[$i] . " Link: " . $uploadlink[$i] . "\n";
                    }
                    }
                    mail($mailto, $subject, stripslashes($message), $header);
                    header('Location: '.$success_url);
                    exit;


                    I guess this must be the spot to load it to and then save and the upload using FTP?
                    Kind Regards
                    Rob
                    www.gnjgf.co.za
                    www.oryan-projects.com

                    Comment

                    • Watdaflip
                      Major General

                      • Sep 2005
                      • 2116

                      #25
                      Re: Form changed to contect to database?

                      Correct, you can add it directly before or after the mail() function. I am not sure what the $uploadlink[] array is, it may or may not work with how the code is now. But give it a try and see if it works.

                      Register/Login Script
                      Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

                      Comment

                      • Rob (SA)
                        Lieutenant Colonel

                        • Nov 2006
                        • 586

                        #26
                        Re: Form changed to contect to database?

                        Hi Watdaflip,

                        I have cut and pasted the options - then used the FTP back to its original posting.

                        It now gives me the blank screeen again.
                        Kind Regards
                        Rob
                        www.gnjgf.co.za
                        www.oryan-projects.com

                        Comment

                        • Watdaflip
                          Major General

                          • Sep 2005
                          • 2116

                          #27
                          Re: Form changed to contect to database?

                          You could be getting an error, change the query from

                          PHP Code:
                          $query mysql_query("INSERT INTO MEMBERS VALUES ('', '$Gender', '$Name', '$Surname', '$Country', '$Date_of_Birth', '$Identity_No', '$P_O_Box', '$Postal_Code', '$Suburb', '$Relationship', '$Language', '$Gaurdians_Name', '$Gaurdians_Surname', '$Cell_Phone', '$Home_phone', '$Work_phone', '$email', '$Division', '$Handicap', '$School', '$Grade', '$Type', '$Membership', '$Home_Club', '$Fax', '$Rules')"$dbconnect); 
                          to

                          PHP Code:
                          $query mysql_query("INSERT INTO MEMBERS VALUES ('', '$Gender', '$Name', '$Surname', '$Country', '$Date_of_Birth', '$Identity_No', '$P_O_Box', '$Postal_Code', '$Suburb', '$Relationship', '$Language', '$Gaurdians_Name', '$Gaurdians_Surname', '$Cell_Phone', '$Home_phone', '$Work_phone', '$email', '$Division', '$Handicap', '$School', '$Grade', '$Type', '$Membership', '$Home_Club', '$Fax', '$Rules')"$dbconnect) or die(mysql_error()); 

                          Register/Login Script
                          Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

                          Comment

                          • simplyjul
                            Private First Class

                            • Dec 2007
                            • 5

                            #28
                            Re: Form changed to contect to database?

                            I am reading this question and answer portion and i am so excited to hear that ROB solve his problem. I have not use any complicated form in my web page yet but soon i will, and when the time comes i'm sure will look for the name "WATDAFLIP" if its ok with him! Good luck guys....
                            http://simplymehere.ca
                            http://realfastmoneyonline.net
                            If You SMOKE make Sure You Earn Money

                            Comment

                            • Rob (SA)
                              Lieutenant Colonel

                              • Nov 2006
                              • 586

                              #29
                              Re: Form changed to contect to database?

                              Hi Watdaflip,

                              Not good news I am afraid.

                              No change.
                              Kind Regards
                              Rob
                              www.gnjgf.co.za
                              www.oryan-projects.com

                              Comment

                              • Watdaflip
                                Major General

                                • Sep 2005
                                • 2116

                                #30
                                Re: Form changed to contect to database?

                                Hmm, send me an email (admin @ [this username].com) and attach the complete file and I will take a look.

                                @simplejul I will do my best to help

                                Register/Login Script
                                Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

                                Comment

                                Working...
                                X