Form changed to contect to database?

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

    • Nov 2006
    • 586

    Form changed to contect to database?

    Hi FOlks,

    I have made some changes to a form in th ehope that it will conect to mySQL.

    Although I dont get any erros the form now does not appear at all and the email address that the info was sent does not now recieve the email.

    I would appreciate some advice on how I can fix this problem or at least someone showing me wher eI am going wrong
    Kind Regards
    Rob
    www.gnjgf.co.za
    www.oryan-projects.com
  • navaldesign
    General & Forum Moderator

    • Oct 2005
    • 12080

    #2
    Re: Form changed to contect to database?

    Rob, how can we help you withour seeing the form AND the code you used ?

    Why don't you use ABVFP ?
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

    Comment

    • Rob (SA)
      Lieutenant Colonel

      • Nov 2006
      • 586

      #3
      Re: Form changed to contect to database?

      Hi George,

      Thanks for the reply.

      The form is one that you created/ assisted me with a while back hence me not using ABVP.

      I have gone to MySQL and created the database as per the instructions.

      I have added some additional info to the form in the hope that it would connect to the database / MySQL. Well the result on publishing is what you see.

      This is what I inserted to my form to create this error.

      <?php
      $MySQL host="localhost";
      $MySQL username="r*****";
      $MySQL password="f*******";
      $MySQL database="eghfya_*******";

      $Gender=$_GET['Gender:'];
      $Name=$_GET['Name'];
      $Surname=$_GET['Surname:'];
      $Country=$_GET['Country:'];
      $Date_of_Birth=$_GET['Date of Birth:'];
      $Identity Number=$_GET['Identity_Number'];
      $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'];
      $Gauerdians Surname=$_GET['Gaurdians Surname'];
      $Cellphone=$_GET['Cellphone'];
      $Home_Phone=$_GET['Home Phone'];
      $Work Phone=$_GET['Work Phone'];
      $Fax=$_GET['Fax'];
      $email=$_GET['email'];
      $Division=$_GET['Division'];
      $Club=$_GET['Club'];
      $School=$_GET['School'];
      $Grade=$_GET['Grade'];
      $Type=$_GET['Type'];
      $Membership=$_GET['Membership'];
      $Rules=$_GET['Rules'];

      $conn1=odbc_connect($eghfya_*****,$******h,$f***** *);
      $query = ("INSERT INTO products VALUES ('', '$Gender', '$Name', '$Surname', '$Country', '$Date of Birth', '$Identity Number', '$P.O.Box', '$Postal Code', '$Suburb', '$Relationship', '$Language', '$Gaurdians Name', '$Gaurdians Surname', '$Cellphone', '$Home Phone', '$Work Phone', '$email', '$Division', '$Handicap', '$School', '$Grade', '$Type', '$Membership', '$Club', '$Rules')");
      ?>


      As you can see I am not the wizz at this type of thing but am trying in order to get somewhere.

      As usual your experiance is valued.
      Kind Regards
      Rob
      www.gnjgf.co.za
      www.oryan-projects.com

      Comment

      • Rob (SA)
        Lieutenant Colonel

        • Nov 2006
        • 586

        #4
        Re: Form changed to contect to database?

        Hi George,

        When I veiw the source after publishing as per normal this is what is revealed.

        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
        <HTML><HEAD>
        <META http-equiv=Content-Type content="text/html; charset=windows-1252">
        <META content=WTMHMJXQED name=SKYPE_FRAMEID>
        <META content=WTMHMJXQED name=SKYPE_FRAMEID>
        <META id=skype_tb_marker_id content=metacontent
        name=SKYPE_PARSING_HAS_FINISHED></HEAD>
        <BODY></BODY></HTML>

        Maybe someone can shed some light on why this occurs?
        Kind Regards
        Rob
        www.gnjgf.co.za
        www.oryan-projects.com

        Comment

        • Watdaflip
          Major General

          • Sep 2005
          • 2116

          #5
          Re: Form changed to contect to database?

          Change your code to something like

          PHP Code:
          <?php
          $MySQLhost
          ="localhost"
          $MySQLusername="r*****"
          $MYSQLpassword="f*******"
          $MySQLdatabase="eghfya_*******";

          $dbconnect mysql_connect($MySQLhost$MySQLusername$MYSQLpassword
          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 Number=$_GET['Identity_Number']; 
          $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']; 
          $Gauerdians Surname=$_GET['Gaurdians Surname']; 
          $Cellphone=$_GET['Cellphone']; 
          $Home_Phone=$_GET['Home Phone']; 
          $Work Phone=$_GET['Work Phone']; 
          $Fax=$_GET['Fax']; 
          $email=$_GET['email'];
          $Division=$_GET['Division'];
          $Club=$_GET['Club'];
          $School=$_GET['School'];
          $Grade=$_GET['Grade'];
          $Type=$_GET['Type'];
          $Membership=$_GET['Membership'];
          $Rules=$_GET['Rules'];

          $query mysql_query("INSERT INTO products VALUES ('', '$Gender', '$Name', '$Surname', '$Country', '$Date of Birth', '$Identity Number', '$P.O.Box', '$Postal Code', '$Suburb', '$Relationship', '$Language', '$Gaurdians Name', '$Gaurdians Surname', '$Cellphone', '$Home Phone', '$Work Phone', '$email', '$Division', '$Handicap', '$School', '$Grade', '$Type', '$Membership', '$Club', '$Rules')"$dbconnect); 
          ?>
          The reason that the page is blank and only has the small amount of html code is because there is no output to the PHP code. When you execute php code it's not going to display the actual code in the browser

          Also you are going to want to validate the data or at least use the addslashes() function otherwise the query will fail when someone enters an apostrophe in one of the fields, or they can do malicious things to your database

          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

            #6
            Re: Form changed to contect to database?

            Hi,

            Thanks for the reply.

            I have made the changes as requested.

            However the blank page still apprears.

            I have made additional changes in that I have removed Skype to the result that the Surce now views as:

            <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
            <HTML><HEAD>
            <META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD>
            <BODY></BODY></HTML>


            It must just be something silly that I cant grasp to be succesful in getting the desired result.

            Again your assitnace would be welcome?
            Kind Regards
            Rob
            www.gnjgf.co.za
            www.oryan-projects.com

            Comment

            • Rob (SA)
              Lieutenant Colonel

              • Nov 2006
              • 586

              #7
              Re: Form changed to contect to database?

              Hi Watdaflip,

              Strangely enough though when I do a previed it shows
              Kind Regards
              Rob
              www.gnjgf.co.za
              www.oryan-projects.com

              Comment

              • Rob (SA)
                Lieutenant Colonel

                • Nov 2006
                • 586

                #8
                Re: Form changed to contect to database?

                Hi FOlks,

                I have got the page back to be able to send the emails after populating the fields.

                Question 1 - how do I know whether the Datbase is being updated?

                Question 2 - Can I create a page that will present the members in a list format that only I can veiw and how easy is it?

                As a rookie that is
                Kind Regards
                Rob
                www.gnjgf.co.za
                www.oryan-projects.com

                Comment

                • Watdaflip
                  Major General

                  • Sep 2005
                  • 2116

                  #9
                  Re: Form changed to contect to database?

                  The reason it shows the code when you preview is because you don't have php install on your computer, so it just displays it as if it were text.

                  Again its not display anything because you haven't told it to display anything. If you want to have it display a message add something like

                  echo "Form submitted";

                  before ?>


                  Check phpmyadmin in cpanel, it will let you look at all of the data stored in your databases.

                  To display the contents on a page use code like..

                  PHP Code:
                  <?php
                  $MySQLhost
                  ="localhost"
                  $MySQLusername="r*****"
                  $MYSQLpassword="f*******"
                  $MySQLdatabase="eghfya_*******";

                  $dbconnect mysql_connect($MySQLhost$MySQLusername$MYSQLpassword
                  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 products"$dbconnect); 

                  echo 
                  '
                  <table>
                       <tr>
                            <td>Gender</td>
                            <td>Name</td>
                            <td>Surname</td>
                       </tr>'
                  ;
                  while(
                  $row mysql_fetch_assoc($select))
                  {
                       echo 
                  '
                            <tr>
                                 <td>'
                  .$row['gender'].'</td>
                                 <td>'
                  .$row['name'].'</td>
                                 <td>'
                  .$row['surname'].'</td>
                             </tr>'
                  ;
                  }
                  echo 
                  '</table>';
                  ?>
                  You will have to add the rest like the current ones are. In the code $row['gender'], gender should correspond with the exact column name in the database. Also make sure you do the header for the top, before the while loop

                  Hope that helps

                  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

                    #10
                    Re: Form changed to contect to database?

                    Hi Watdaflip,

                    Thanks for the inputs.

                    Lik eI said I am very new to this concept and am really moving between advice from one to another in getting the final result.

                    I will endevour to follow your lead and reply later
                    Kind Regards
                    Rob
                    www.gnjgf.co.za
                    www.oryan-projects.com

                    Comment

                    • Rob (SA)
                      Lieutenant Colonel

                      • Nov 2006
                      • 586

                      #11
                      Re: Form changed to contect to database?

                      Hi Watdaflip,

                      A question.

                      In writing all this scrpit as we have done.

                      Do I paste this info on my page and where about must it be posted exactly.

                      This could also be a major part of my problem in that I am not placing it in the correct place.
                      Kind Regards
                      Rob
                      www.gnjgf.co.za
                      www.oryan-projects.com

                      Comment

                      • Watdaflip
                        Major General

                        • Sep 2005
                        • 2116

                        #12
                        Re: Form changed to contect to database?

                        This particular script you can place anywhere. Just copy and paste it in a html box, publish as a php file, and your set.

                        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

                          #13
                          Re: Form changed to contect to database?

                          Hi,

                          Thanks for the reply.

                          Thats a blessing as I had visions of starting this all over
                          Kind Regards
                          Rob
                          www.gnjgf.co.za
                          www.oryan-projects.com

                          Comment

                          • Rob (SA)
                            Lieutenant Colonel

                            • Nov 2006
                            • 586

                            #14
                            Re: Form changed to contect to database?

                            Hi Watdaflip,

                            I have made all the changes as suggested.

                            The emailing portion working fine.

                            The visual of the table outside MySql nothing seen.

                            I cant see the info in my Members datbase once I have submitted
                            Kind Regards
                            Rob
                            www.gnjgf.co.za
                            www.oryan-projects.com

                            Comment

                            • Watdaflip
                              Major General

                              • Sep 2005
                              • 2116

                              #15
                              Re: Form changed to contect to database?

                              Post the code you are currently using (you can censor the db password and stuff) but make sure the queries are unaltered.

                              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