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

    Loading jotform form data to mysql database - error message on my php script

    Asked by embscareers on April 26, 2013 at 09:21 AM

    Hello,

     

    Thanks for the script. It works as charm for me. The only one problem I have is that when I include the item "file" for the submitted document. The thank you page shows me that : Unknown column 'file' in 'field list'

     

    That's the code I have:

     

     

    //print_r($_POST);

     

    // 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);

     

    $submission_id = $_POST['submission_id'];

    $formID = $_POST['formID'];

    $ip = $_POST['ip'];

    $name = $_POST['name'];

    $email = $_POST['email'];

    $phonenumber = $_POST['phonenumber13'][0] ."-". $_POST['phonenumber13'][1];

    $subject = $_POST['subject7'];

    $message = $_POST['message6'];

    $file = $_POST['file'];

     

     

     

    mysql_connect( $db_host, $db_username, $db_password) or die(mysql_error());

    mysql_select_db($db_name);

     

    // search submission ID

     

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

    $sqlsearch = mysql_query($query);

    $resultcount = mysql_numrows($sqlsearch);

     

    if ($resultcount > 0) {

     

    mysql_query("UPDATE `candidates` SET

    `name` = '$name',

    `email` = '$email',

    `phone` = '$phonenumber',

    `subject` = '$subject',

    `message` = '$message'

    `file` = '$file'

    WHERE `submission_id` = '$submission_id'")

    or die(mysql_error());

     

    } else {

     

    mysql_query("INSERT INTO `candidates` (submission_id, formID, IP,

    name, email, phone, subject, message,file)

    VALUES ('$submission_id', '$formID', '$ip', '$name', '$email', '$phonenumber', '$subject', '$message','$file') ")

    or die(mysql_error());

     

    }

    ?>

    Thank you! Your submission has been received.



    This is a re-post of a comment on How to send Submissions to Your MySQL Database Using PHP

    problem thanks hello email POST name
  • Profile Image
    JotForm Founder

    Answered by aytekin on April 26, 2013 at 09:35 AM

    I recommend changing your mysql password since you publicly posted your password on the comment. I removed it from the post but you might want to change it anyways. 

    The error message comes from mysql. This query is incorrect:

    mysql_query("INSERT INTO `candidates` (submission_id, formID, IP, name, email, phone, subject, message,file)

    Your candidates table does not have a file field. Either add that field or change the field name to the correct column name. 

     


  • Profile Image

    Answered by embscareers on April 29, 2013 at 04:20 AM

    Hello Aytekin, 

    Thanks for the reply, it was very useful. 

    As you were right, I forgot to include the table in the database. Now when I submit the application, it recognize the name of the file I upload, but it's not working as a link. In the database is stored as a VARCHAR, 250 characters of length.

    Example:

    I did a test uploading the file: analytics review website.pdf

    and in the file were I call the data from the database comes as:

    Analytics Review Website.pdf   

    (but not clickable)

    It will great if you can help me to understand what is the problem.

    Thanks again!  

  • Profile Image
    JotForm Support

    Answered by Welvin on April 29, 2013 at 10:44 AM

    Hi,

    We'll try to get back to you later today for the solution on how you can retrieve the download link. I think there's something you need to do to have this.

     

    Thanks

  • Profile Image

    Answered by embscareers on April 29, 2013 at 02:21 PM

    Thanks Welvin, 

     

    I´m looking forward to your response.

    Cheers!

  • Profile Image
    JotForm Support

    Answered by liyam on April 29, 2013 at 03:23 PM

    Hello embscareers.  Unfortunately, the download link is not available from the post data.  However, you can manually create the download link based from the post data provided to your page

    Coming from the variables you have shared, you can build the link and print it by following this:

     $linkfile = "http://www.jotform.com/uploads/embscareers/". $formID ."/". $submission_id ."/". $file;

    So assuming that you have these following details:

         $formID = 31112954391349
         $submission_id = 233031863471974555
         $file = Analytics Review Website.pdf

    It will then form this URL:

         http://www.jotform.com/uploads/embscareers/31112954391349/233031863471974555/Analytics Review Website.pdf

    Now, if you want it to be clickable, simply do this:

        <a target="_blank" href="<? echo $linkfile; ?>"> <?php echo $linkfile; ?> </a>

    I'm not sure if you get the idea of what I'm explaining, but if you have further questions, just throw 'em in, and we'll answer :)

  • Profile Image

    Answered by jeronimowillis on May 25, 2013 at 02:42 PM

    Get error message rid of due to mysql recovery, article open to you all solutions solve like troubles

  • Profile Image

    Answered by embscareers on May 26, 2013 at 05:10 AM

    Hey guys

     

    Sorry @Liyam for my delayed answer, but the first part of your solution  worked like charm! :)

    Now Im gonna try with the clickable feature.

     

    Thank you very much!

    You guys are great:)

  • Profile Image
    JotForm Support

    Answered by jonathan on May 26, 2013 at 11:07 AM

    @embscareers

    Hi,

    Thank you for updating us. We're glad to know that the solution by Liyam works for you.

    Contact us again anytime should you have other question.

     

    Best Regards,

  • Profile Image

    Answered by markmohan on May 29, 2013 at 07:49 AM

    Hello,

    It semms that you mysql database is corrupted so you face this problem,you can try to use Kernel for MySQL Database Recovery software, which efficiently repairs MyIASM format database and generates the required data. It also allows accessing the MySQL database from any remote place in the network and save the recovered data.

  • Profile Image

    Answered by khrisell on July 04, 2013 at 11:28 PM
    Greetings!

    We are happy to announce that we have released Jotform Webhooks,  this feature would replace Send Post Data + Custom URL Thank You Page workaround in order to help you transfer forms data to your own database using your own script codes.

    To know more about Jotform Webhooks, please click here.

     

    Thank you for using JotForm. :)

  • Profile Image

    Answered by embscareers on July 05, 2013 at 03:35 AM

    Hello!

     

    Thanks for the info. My question is, if I actually have something set up with send post data + custom URL thank you, it will not work anymore?  

  • Profile Image
    JotForm Support

    Answered by EltonCris on July 05, 2013 at 04:24 AM

    @embscareers

    No, they should still work. They are still available on the form preferences. Webhook is a more advanced one but you can still make use of the post data + custom URL.

    Thanks!