What is JotForm?
JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.

At JotForm, we want to make sure that you’re getting the online form builder help that you need. Our friendly customer support team is available 24/7.

We believe that if one user has a question, there could be more users who may have the same question. This is why many of our support forum threads are public and available to be searched and viewed. If you’d like help immediately, feel free to search for a similar question, or submit your question or concern.


  • Profile Image

    User Edits/Updates Not Posting to MySql

    Asked by ellie123 on July 11, 2014 at 01:47 PM

    Hello - My form is is setup and posting perfect to MySql table - everything is working great. No errors and all my info is accessible.

    However, when the user clicks on the EDIT link in their auto responder email and makes any changes to the form the edits are not posting to my database.

    Is there any code samples that I can see to ensure that I have written mine correctly?

    I used the sample code that was posted here in the Form to write my POST custom thank you page.

    If you have any other ideas as to what might cause this prob, I'd love to hear....thank you :)

    Page URL:
    http://form.jotform.us/form/41855520219150

    Auto Responder Email POST custom thank you edit link
  • Profile Image
    JotForm Support

    Answered by BDAVID on July 11, 2014 at 02:36 PM

    In this case you should have a conditional statement that checks if the submissions ID exist, if it exist, it will update the submissions, otherwise if not, it will create a new data entry on the database, like this example:

    if ($resultcount > 0) {
     
        mysql_query("UPDATE `table_name` SET 
                                    `name` = '$name',
                                    `email` = '$email',
                                    `phone` = '$phonenumber',
                                    `subject` = '$subject',
                                    `message` = '$message'        
                                 WHERE `submission_id` = '$submission_id'"
         or die(mysql_error());
        
    else {

        mysql_query("INSERT INTO `table_name` (submission_id, formID, IP, 
                                                                              name, email, phone, subject, message) 
                                   VALUES ('$submission_id', '$formID', '$ip', 
                                                     '$name', '$email', '$phonenumber', '$subject', '$message') "
        or die(mysql_error());  

    }

    ?>

    You can take a look this guide "How to send Submissions to Your MySQL Database Using PHP". If you already did it, please provide us your code, so we can check further.

  • Profile Image

    Answered by ellie123 on July 11, 2014 at 09:13 PM

    Need help please - I'm sooo frustrated...

    No matter what form I try, I cannot get the user edits to submit to mysql db. I get an error EVERY TIME. The form data posts perfect the first time the user submits the form.

    But if they click on the EDIT link in their email, they get an error after pressing SUBMIT when they've made any changes to the form and their edits are not reflected in the db.

    I literally copied and pasted the sample code that is in the How-To-Send-Submissions-To-Your-Database Forum Post. So, I can't figure out how I can have an error? 

    This is my error:
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''email'='maxwellellie@gmail.com', 'dineragreement'='N/A', 'onsitesubmitted'='N/A' at line 2

    Here is my form: http://form.jotform.us/form/41784913453157

    Here is my PHP (I have XXX out my DB user/pass):

    <?php

    // This function will run within each post array including multi-dimensional arrays 

    function ExtendedAddslash(&$params)

            foreach ($params as &$var) {

                // check if $var is an array. If yes, it will start another ExtendedAddslash() function to loop to each key inside.

                is_array($var) ? ExtendedAddslash($var) : $var=addslashes($var);

                unset($var);
           }

    }
       // Initialize ExtendedAddslash() function for every $_POST variable

        ExtendedAddslash($_POST);      
    ?>

    <?php
    $submission_id=$_POST['submission_id'];
    $formID=$_POST['formID'];
    $ip=$_POST['ip'];
    $email=$_POST['email'];
    $dineragreement=$_POST['dineragreement'];
    $onsitesubmitted=$_POST['onsitesubmitted'];
    $finalreport=$_POST['finalreport'];
    $dineragreement18=$_POST['dineragreement18'];
    $onsitedone=$_POST['onsitedone'];
    $finaldone=$_POST['finaldone'];
    $checkamp=$_POST['checkamp'];
    $checkimage=$_POST['checkimage'];
    $creditcard=$_POST['creditcard'];
    ?>

     <?php

    $db_host = 'localhost';
    $db_username = 'XXXXXX';
    $db_password = 'XXXXXX';
    $db_name = 'XXXXXX';

    mysql_connect( $db_host, $db_username, $db_password) or die(mysql_error());
    mysql_select_db($db_name);
    ?>

    <?php 

    // search submission ID

    $query = "SELECT * FROM `jotstatus` WHERE `submission_id` = '$submission_id'";

    $sqlsearch = mysql_query($query);
    $resultcount = mysql_numrows($sqlsearch);

    if ($resultcount > 0) {

         mysql_query("UPDATE `jotstatus` SET 
    'email'='$email',
    'dineragreement'='$dineragreement',
    'onsitesubmitted'='$onsitesubmitted',

    'finalreport'='$finalreport',
    'dineragreement18'='$dineragreement18',
    'onsitedone'='$onsitedone',
    'finaldone'='$finaldone',
    'checkamp'='$checkamp',
    'checkimage'='$checkimage',
    'creditcard'='$creditcard'

                                 WHERE `submission_id` = '$submission_id'") 

         or die(mysql_error());

    } else {

        mysql_query("INSERT INTO `jotstatus` (submission_id,formID,ip,email,dineragreement,onsitesubmitted,finalreport,dineragreement18,onsitedone,finaldone,checkamp,checkimage,creditcard) 

                                   VALUES ('$submission_id','$formID','$ip','$email','$dineragreement','$onsitesubmitted','$finalreport','$dineragreement18','$onsitedone','$finaldone','$checkamp','$checkimage','$creditcard') ") 

        or die(mysql_error());  

    }
    ?>

    Any help you can provide is greatly appreciated....I have this same setup on 3 forms and I have this same problem on all 3. So it's obviously something I am not doing right...

     

    - Ellie

     

     

  • Profile Image
    JotForm Support

    Answered by Welvin on July 12, 2014 at 03:53 AM

    Hi Ellie,

    We'll check this for you and get back to you later today. 

    Thanks