Trying to capture form info on database

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Rob
    Second Lieutenant

    • Oct 2005
    • 126

    Trying to capture form info on database

    Hi All,

    I have a form on our contact page. This presently sends the message to us as an email using a php script . We would like to capture this information on a database automatically. I have watched the tutorials on how to set up and manage a database through the control panel but am still confused as to what we actually need to do make the information that is put into the form arrive as an email and go to a data base. Do we need to change or add anything to the php scrip or if we don't how does it end up in the right place.

    I am sure it is not as confusing as I am making it !.

    Rob

    www.saulfarm.com
    www.saulfarm.com
    www.pumfrett.com
    www.dampguard.com
    www.zakoapartments.com
  • navaldesign
    General & Forum Moderator

    • Oct 2005
    • 12080

    #2
    Re: Trying to capture form info on database

    Yes, you can write info in your database directly from the php script. You need to have a part of the script specifically writen to accompish this. Also, if you use Pablo's script, it will only be able to define and wite the email to the database. If you need more fields, the sctipt has to be modified.
    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
      Second Lieutenant

      • Oct 2005
      • 126

      #3
      Re: Trying to capture form info on database

      Hi Navaldesign,

      Thanks for your help.

      Is it best to write info in your database directly from the php script or would you recomend another way of doing it as changing the script so it achieves the capture of all the info' sounds pretty complicated !

      thanks,

      Rob

      www.saulfarm.com
      www.saulfarm.com
      www.pumfrett.com
      www.dampguard.com
      www.zakoapartments.com

      Comment

      • navaldesign
        General & Forum Moderator

        • Oct 2005
        • 12080

        #4
        Re: Trying to capture form info on database

        [Well, there is always the manual way of doing it. If you do have a database management inteface script (which i suppose you do have, otherwise what would you do of a database?) then you can update it manually. However, i do have a database writing script. If you want we may try it. And no, it doesn't seem so complicated. I have never tried it though. I will need the name of the database, the name of the table, and username / password of the database. I will also need the URL of the form. Make sure your form is in it's final version
        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
          Second Lieutenant

          • Oct 2005
          • 126

          #5
          Re: Trying to capture form info on database

          Hi Navel D,

          Should I set up a new database in the control panel and give it name. UN and PW should be part of this process I think ? Not sure about the 'table' ? and is the URL of the form the contact page on the website containing the form or the php page containing the script.

          Sorry to be obtuse, but you can see why I'm finding it complicated.

          Thanks for bearing with me.

          Rob
          www.saulfarm.com
          www.pumfrett.com
          www.dampguard.com
          www.zakoapartments.com

          Comment

          • navaldesign
            General & Forum Moderator

            • Oct 2005
            • 12080

            #6
            Re: Trying to capture form info on database

            Originally posted by Rob
            Hi Navel D,

            Should I set up a new database in the control panel and give it name. UN and PW should be part of this process I think ? Not sure about the 'table' ? and is the URL of the form the contact page on the website containing the form or the php page containing the script.

            Sorry to be obtuse, but you can see why I'm finding it complicated.

            Thanks for bearing with me.

            Rob
            1. Yes, you must set up a new database.
            2. Username and password will be defined during the setup process. 3. Databases have tables where you write the data. Every table has fields.

            F.e. a client database may have one table for client info, one table for client's posts, one table for client's purchses (or licenses) etc.
            Every table has more fields f.e. the client info table has fields for Address, Tel, Cel, Fax, and so on.
            4. I need the form Url to see your fields.

            Question, if i am allowed: i can see that you are just starting to learn something about MySQL. Even if i give you a script to handle data uploading in the database, what are you going to do with it? you need a php interface script to handle the database info. Also to be able to manually update, modify, download etc. Then this script must have the ability to create html pages fpr the presentation of the results. Also, you must be able to create and handle querries, otherwise the database will be of no use at all. Are you sure you can handle this? This is more than a complex project, and when i do it, i get paid well for it. Do you feel like facing this kind of job?
            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
              Second Lieutenant

              • Oct 2005
              • 126

              #7
              Re: Trying to capture form info on database

              Hi Naveldesign,

              Name of database: saul contact form
              UN: richard
              PW: bookers

              Name of table: saul

              form is at: http://www.saulfarm.com/contact.html

              Th4e information we would like to capture is on the form at the above page. There are 7 fields.

              Thanks

              Rob
              www.saulfarm.com
              www.pumfrett.com
              www.dampguard.com
              www.zakoapartments.com

              Comment

              • navaldesign
                General & Forum Moderator

                • Oct 2005
                • 12080

                #8
                Re: Trying to capture form info on database

                here is your script:

                <?php

                // Receiving variables
                @$Title = addslashes($_POST['Title']);
                @$First_Name = addslashes($_POST['First_Name']);
                @$Suname = addslashes($_POST['Suname']);
                @$Tel_No = addslashes($_POST['Tel_No']);
                @$Email = addslashes($_POST['Email']);
                @$Subject = addslashes($_POST['Subject']);
                @$Message = addslashes($_POST['Message']);

                //Sending Email to form owner
                $pfw_header = "From: $Email\n"
                . "Reply-To: $Email\n";
                $pfw_subject = "Put your Subject here";
                $pfw_email_to = "youremail@yourvodahostdomain.com ";
                $pfw_message = "Info Submitted from Contact Webform\n"
                . "----------------------------------------------\n"
                . "\n"
                . "Title: $Title\n"
                . "First_Name: $First_Name\n"
                . "Suname: $Suname\n"
                . "Tel_No: $Tel_No\n"
                . "Email: $Email\n"
                . "Subject: $Subject\n"
                . "Message: $Message\n";
                *****($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;
                //saving record to MySQL database

                @$pfw_strQuery = "INSERT INTO `saul`(`titlefieldname`,`firstnamefieldname`,`surn amefieldname`,`telfieldname`,`emailfieldname`,`sub jectfieldname`,`messagefieldname`)VALUES (\"$Title\",\"$First_Name\",\"$Suname\",\"$Tel_No\ ",\"$Email\",\"$Subject\",\"$Message\")" ;
                @$pfw_host = "localhost";
                @$pfw_user = "richard";
                @$pfw_pw = "bookers";
                @$pfw_db = "saul_contact_form";
                $pfw_link = mysql_connect($pfw_host, $pfw_user, $pfw_pw);
                if (!$pfw_link) {
                die('Could not connect: ' . mysql_error());
                }
                $pfw_db_selected = mysql_select_db($pfw_db, $pfw_link);
                if (!$pfw_db_selected) {
                die ('Can not use $pfw_db : ' . mysql_error());
                }
                //insert new record
                $pfw_result = mysql_query($pfw_strQuery);
                if (!$pfw_result) {
                die('Invalid query: ' . mysql_error());
                }
                mysql_close($pfw_link);
                header("Location: thankyou_page.html");
                ?>


                Please change the subject and email in the script. Also change the "titlefiledname", "firstnamefieldname" etc. to be the real manes of your fields.

                Create a simple html page in BV, name it "thankyou_page" save it and publish it. This will be the page where they will get redirected to after submission.

                Copy/paste the script in notepad (or in your favorite php editor if you have one). Modify iy as instructed above. Save it as "contact.php". If you use notepad, to accomplish this you must go in "Save as", the choose File tyoe: "All files", and type in as name: "contact.php". Upload the saved file on your site.
                Make sure the "action" of your form is "contact.php" and the encoding "multipart/ form data".

                Please also note that the name of your database has probably automaticaly been changed in "saul_contact_form" with underscores. Verify this, as i have asumed it is so, but i can't be certain. Enter your CP, go in MySQL databases, and check the name of your database in your CP.
                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
                  Second Lieutenant

                  • Oct 2005
                  • 126

                  #9
                  Re: Trying to capture form info on database

                  Hi Naveldesign,

                  Received your message sent through the form to our email

                  The php script we are using is:

                  <HEAD>
                  <TITLE>Succesfully processed your Report</TITLE>
                  </HEAD>
                  <BODY>
                  <H2>Thank you for your enquiry!</H2>
                  <?PHP
                  $email = $HTTP_POST_VARS[email];
                  $mailto = "rob@saulfarm.com";
                  $mailsubj = "Saul contact form";
                  $mailhead = "From: $email\n";
                  reset ($HTTP_POST_VARS);
                  $mailbody = "Values submitted from web site form:\n";
                  while (list ($key, $val) = each ($HTTP_POST_VARS))
                  {
                  $mailbody .= "$key : $val\n";
                  }
                  mail($mailto, $mailsubj, $mailbody, $mailhead);
                  ?>
                  </BODY>
                  </HTML>

                  Should I replace this script with the one you have just sent.

                  Regards

                  Rob

                  www.saulfarm.com
                  www.saulfarm.com
                  www.pumfrett.com
                  www.dampguard.com
                  www.zakoapartments.com

                  Comment

                  • navaldesign
                    General & Forum Moderator

                    • Oct 2005
                    • 12080

                    #10
                    Re: Trying to capture form info on database

                    Yes, you must replace it after the changes. Please keep a backup of your original script, just in case.
                    Please tell me: you did receive the email address of your visitors, but i think you received it as info sent, not in the FROM of the email, correct?
                    Because in your form the field is Email whilst in the script it is email ( Lowercase E)
                    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
                      Second Lieutenant

                      • Oct 2005
                      • 126

                      #11
                      Re: Trying to capture form info on database

                      Hi Naveldesign,

                      For some reason although the database is set up I can't get to set up the table. I have named the table and put 7 in the box for number of fields and at the top of the page it shows its added a table. When you click on the table to edit it it goes back to the original page.

                      I've not changed the script as I thought best not until confident database is configured properly.

                      We received the message you sent as from our form straight to our outlook inbox as follows:

                      Values submitted from web site form:
                      Submit : Submit
                      Title : Mr
                      First_Name : Giorgio
                      Suname : Navaldesign
                      Tel_No : 9999999
                      Email : xxxxxxxx@navaldesign.info
                      Subject : Bed and breakfast
                      Message : Please let me know if you have received this. I need to have also the contact.php script that you are using

                      Thanks,

                      Rob
                      Last edited by navaldesign; 03-30-2006, 03:42 PM.
                      www.saulfarm.com
                      www.pumfrett.com
                      www.dampguard.com
                      www.zakoapartments.com

                      Comment

                      • navaldesign
                        General & Forum Moderator

                        • Oct 2005
                        • 12080

                        #12
                        Re: Trying to capture form info on database

                        Yes, i know you did receive the visitor's email in the message body. What i was asking is if you received it also in the "From" tag, or the from tag was emtpy.

                        To edit the table field names, go to phpMyAdmin. You will find the link at the bottom of the MySQL Databases page in your CP
                        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
                          Second Lieutenant

                          • Oct 2005
                          • 126

                          #13
                          Re: Trying to capture form info on database

                          Hi,

                          The from tag was empty.


                          Have now been able to open the tabbe to enter the fields. I put in all 7 fields. The other boxes on the table are:

                          Type length/values Collation Attributes Null Default** Extra

                          I didn't know what to put in these so I just clicked save at the bottom and a box opened asking to enter a number, I think for Lenght/values ?

                          I feel I'm getting closer, but not quite there yet I'm afraid.

                          Thanks

                          Rob

                          www.saulfarm.com
                          www.saulfarm.com
                          www.pumfrett.com
                          www.dampguard.com
                          www.zakoapartments.com

                          Comment

                          • navaldesign
                            General & Forum Moderator

                            • Oct 2005
                            • 12080

                            #14
                            Re: Trying to capture form info on database

                            Enter the desired lenght for the fields.
                            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
                              Second Lieutenant

                              • Oct 2005
                              • 126

                              #15
                              Re: Trying to capture form info on database

                              Based on the 7 field types

                              Title
                              First name
                              Surname
                              Tel number
                              Email
                              Subject
                              Message

                              What should the field lengths be ?

                              Rob

                              www.saulfarm.com
                              www.saulfarm.com
                              www.pumfrett.com
                              www.dampguard.com
                              www.zakoapartments.com

                              Comment

                              Working...
                              X