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

    .php File post data - displaying script on website HELP!!

    Asked by memaxt on September 03, 2014 at 07:22 AM

    Hi there,

    I've uploaded my .php file using your guide on how to post data to .PHP then to MySQL.

    I've created a test form: Test

    I have 1 field: Name.

    When I submit the website displays the following:

    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']; $db_host = 'mysql8.namesco.net'; $db_username = 'XXXX'; $db_password = 'XXXXX'; $db_name = 'PH500534_cdreportingc'; mysql_connect( $db_host, $db_username, $db_password) or die(mysql_error()); mysql_select_db($db_name); // search submission ID $query = "SELECT * FROM `Test` WHERE `submission_id` = '$submission_id'"; $sqlsearch = mysql_query($query); $resultcount = mysql_numrows($sqlsearch); if ($resultcount > 0) { mysql_query("UPDATE `test` SET `name` = '$name', WHERE `submission_id` = '$submission_id'") or die(mysql_error()); } else { mysql_query("INSERT INTO `test` (submission_id, formID, IP, name) VALUES ('$submission_id', '$formID', '$ip', '$name') ") or die(mysql_error()); }

    ?>

    which is the script itself, I have removed username and password "XXXX"

    why is it dispalying this and not sending the data to mysql?

    Many thanks

    Max

     

    POST post data name submission id
  • Profile Image

    Answered by jedcadorna on September 03, 2014 at 09:53 AM

    Hi Max,

    I'll have to test this first as I rarely use PHP so I have to make some test. Probably some mismatch when calling or inserting in your MySQL database. We'll get back to you once I find an answer to this.

  • Profile Image

    Answered by memaxt on September 03, 2014 at 11:12 AM

    Hi there,

    Thank you for looking into this

    Have you had any luck?

  • Profile Image

    Answered by jedcadorna on September 03, 2014 at 11:33 AM

    Is that really your starting code print_r( $_POST ); ?>? It should start with <?php print_r( $_POST ); ?>. If that is the start of your code then you are missing the PHP opening tag <?php.

    You can also share the complete code so we could check on our end if that is not the actual code you have in your cd.php page.

  • Profile Image

    Answered by aadrinmusic on September 03, 2014 at 11:38 AM

    Hi,

    I did a screenshot in the browser's View Page Source and I saw at the top of your PHP file that the PHP tag was terminated with a semicolon. See the image below in line 2 (<?php;). Remove the semicolon, save the file and try again.

     

     

    If this didn't resolve your issue, please send the .php file so we can take a closer look.