Confusion regarding post data names vs DB column names.

  • Profile Image
    Asked on September 01, 2016 at 01:44 AM

    Hi there. I have been successful in connecting my form to my data base using a php script and have been able to pass the data using the default post data value/column names in my database. How ever now I am wondering how I insert the post data into the database using my own specified column names rather than the post data naming scheme that jotforms gives me. (Which particular section of code do I edit/change the names of?)

    For example.


    We have been using these names as our column names in our database in order to pass and store the data, and it works fine.
    We now want to insert the same data into columns of which we have named ourselves. eg

    $_POST['categoryof25']; instead of category25 being the column name in our DB we would like to name it category_of_incident
    Below is my current PHP script.

  • Profile Image
    Answered on September 01, 2016 at 01:46 AM



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




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



    $submission_id = $_POST['submission_id']; 

    $formID = $_POST['formID'];

    $ip = $_POST['ip'];

    $categoryof = $_POST['categoryof25'];

    $hsc_first_name = $_POST['hscfirst'];

    $hsc_last_name = $_POST['hsclast'];

    $date = $_POST['date'];

    $time = $_POST['time23'];

    $location = $_POST['location'];

    //People involved

    $how_many_ppl = $_POST['howmany'];

    $name_1 = $_POST['name'];

    $position_1 = $_POST['position'];

    $time_with_comp_1 = $_POST['timewith61']['0'];

    $name_2 = $_POST['individual2'];

    $position_2 = $_POST['position74'];

    $time_with_comp_2 =  $_POST['timewith60']['0'];

    $name_3 = $_POST['individual3'];

    $position_3 = $_POST['position75'];

    $time_with_comp_3 = $_POST['timewith57']['0'];

    $name_4 = $_POST['individual4'];

    $position_4 = $_POST['position70'];

    $time_with_comp_4 = $_POST['timewith53']['0'];

    $name_5 = $_POST['individual5'];

    $position_5 = $_POST['position71'];

    $time_with_comp_5 = $_POST['timewith54']['0'];


    $were_injuries = $_POST['werethere'];

    $type_of_injury = $_POST['typeof'] ['0'];$_POST['typeof']['1'];$_POST['typeof']['2'];$_POST['typeof']['3'];$_POST['typeof']['4'];$_POST['typeof']['5'];$_POST['typeof']['6'];$_POST['typeof']['7'];$_POST['typeof']['8'];$_POST['typeof']['9'];$_POST['typeof']['10'];$_POST['typeof']['11'];$_POST['typeof']['12'];

    $inj_name_1 = $_POST['individual1'];

    $is_injured_1 = $_POST['injured'];

    $severity_1 = $_POST['severity99'];

    $describe_injury_1 = $_POST['describeinjury82'];

    $inj_name_2 = $_POST['individual287'];

    $is_injured_2 = $_POST['injured92'];

    $severity_2 = $_POST['severity101'];

    $describe_injury_2 = $_POST['describeinjury97'];

    $inj_name_3 = $_POST['individual386'];

    $is_injured_3 = $_POST['injured91'];

    $severity_3 = $_POST['severity102'];

    $describe_injury_3 = $_POST['describeinjury96'];

    $inj_name_4 = $_POST['individual485'];

    $is_injured_4 = $_POST['injured90'];

    $severity_4 = $_POST['severity103'];

    $describe_injury_4 = $_POST['describeinjury95'];

    $inj_name_5 = $_POST['individual598'];

    $is_injured_5 = $_POST['injured89'];

    $severity_5 = $_POST['severity104'];

    $describe_injury_5 = $_POST['describeinjury94'];

    $frequency = $_POST['frequency'];

    $poten_serious_harm = $_POST['didthe'];


    $property_damage = $_POST['wasthere'];

    $describe_damage = $_POST['describedamage'];

    $cause_of_damage =  $_POST['cause']['0'];$_POST['cause']['1'];$_POST['cause']['2'];$_POST['cause']['3'];$_POST['cause']['4'];$_POST['cause']['5'];$_POST['cause']['6'];$_POST['cause']['7'];$_POST['cause']['8'];$_POST['cause']['9'];$_POST['cause']['10'];$_POST['cause']['11'];$_POST['cause']['12'];$_POST['cause']['13'];$_POST['cause']['14'];$_POST['cause']['15'];$_POST['cause']['16'];$_POST['cause']['17'];$_POST['cause']['18'];$_POST['cause']['19'];$_POST['cause']['20'];

    $cause_of_incident = $_POST['descriptionof14'];

    $fixed_damages =  $_POST['whathas'];

    $prevented_repeat = $_POST['whathas34'];


    $db_host = '';

    $db_username = '';

    $db_password = '';

    $db_name = '';

    $table_name = '';


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



    // search submission ID


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

    $sqlsearch = mysql_query($query);

    $resultcount = mysql_num_rows($sqlsearch);


    if ($resultcount > 0) {


        mysql_query("UPDATE $table_name SET 

                                    `categoryof25` = '$categoryof',

                                    `hscfirst` = '$hsc_first_name',

                                    `hsclast` = '$hsc_last_name',

                                    `date` = '$date',

                                    `time23` = '$time',

                                    `location` = '$location',

                                    `howmany` = '$how_many_ppl',

                                    `name` = '$name_1',

                                    `position` = '$position_1',

                                    `timewith61` = '$time_with_comp_1',

                                    `individual2` = '$name_2',

                                    `position74` = '$position_2',

                                    `timewith60` = '$time_with_comp_2',

                                    `individual3` = '$name_3',

                                    `position75` = '$position_3',

                                    `timewith57` = '$time_with_comp_3',

                                    `individual4` = '$name_4',

                                    `position70` = '$position_4',

                                    `timewith53` = '$time_with_comp_4',

                                    `individual5` = '$name_5',

                                    `position71` = '$position_5',

                                    `timewith54` = '$time_with_comp_5',

                                    `werethere` = '$were_injuries',

                                    `typeof` = '$type_of_injury', 


                                    `individual1` = '$inj_name_1',

                                    `injured` = '$is_injured_1',

                                    `severity99` = '$severity_1',

                                    `describeinjury82` = '$describe_injury_1',


                                    `individual287` = '$inj_name_2',

                                    `injured92` = '$is_injured_2',

                                    `severity101` = '$severity_2',

                                    `describeinjury97` = '$describe_injury_2',


                                    `individual386` = '$inj_name_3',

                                    `injured91` = '$is_injured_3',

                                    `severity102` = '$severity_3',

                                    `describeinjury96` = '$describe_injury_3',


                                    `individual485` = '$inj_name_4',

                                    `injured90` = '$is_injured_4',

                                    `severity103` = '$severity_4',

                                    `describeinjury95` = '$describe_injury_4',


                                    `individual598` = '$inj_name_5',

                                    `injured89` = '$is_injured_5',

                                    `severity104` = '$severity_5',

                                    `describeinjury94` = '$describe_injury_5',


                                    `frequency` = '$frequency',

                                    `didthe` = '$poten_serious_harm',

                                    `wasthere` = '$property_damage',

                                    `describedamage` = '$describe_damage',

                                    `cause` = '$cause_of_damage',

                                    `descriptionof14` = '$cause_of_incident',

                                    `whathas` = '$fixed_damages',

                                    `whathas34` = '$prevented_repeat'



                                 WHERE 'submission_id' = '$submission_id'") 

         or die(mysql_error());


    } else {


        mysql_query("INSERT INTO $table_name (submission_id, categoryof25, hscfirst, hsclast, date, time23, location, 

            howmany, name, position, timewith61, individual2, position74, timewith60, individual3, position75, timewith57, individual4, position70, timewith53, individual5, position71, timewith54, 

            werethere, typeof, 

            individual1, injured, severity99, describeinjury82, 

            individual287, injured92, severity101, describeinjury97, 

            individual386, injured91, severity102, describeinjury96, 

            individual485, injured90, severity103, describeinjury95, 

            individual598, injured89, severity104, describeinjury94, 

            frequency, didthe, wasthere, describedamage, cause, descriptionof14, whathas, whathas34)




                                   VALUES ('$submission_id', '$categoryof', '$hsc_first_name', '$hsc_last_name','$date','$time','$location', '$how_many_ppl', '$name_1', '$position_1', '$time_with_comp_1', '$name_2', '$position_2', '$time_with_comp_2', '$name_3', '$position_3', '$time_with_comp_3', '$name_4', '$position_4', '$time_with_comp_4', '$name_5', '$position_5', '$time_with_comp_5', '$were_injuries', '$type_of_injury', '$inj_name_1', '$is_injured_1', '$severity_1', '$describe_injury_1', '$inj_name_2', '$is_injured_2', '$severity_2',  '$describe_injury_2', '$inj_name_3', '$is_injured_3', '$severity_3', '$describe_injury_3', '$inj_name_4', '$is_injured_4', '$severity_4', '$describe_injury_4', '$inj_name_5', '$is_injured_5', '$severity_5; '$describe_injury_5', '$frequency', '$poten_serious_harm', '$property_damage', '$describe_damage', '$cause_of_damage', '$cause_of_incident', '$fixed_damages', '$prevented_repeat')")

        or die(mysql_error());  






  • Profile Image
    Answered on September 01, 2016 at 04:54 AM

    To change the POST name of the form, simply follow the steps below:

    1. Select the field and click the gear icon to open Properties

    2. On the properties wizard, select the Advanced tab and click Field Details

    3. Enter your desired POST name in the Unique Name field. Save changes when done.

    4. Do the same to the rest of the fields and you should now have your custom POST names for all of them.

    Here's how the category should look after:

    If you need further assistance, please let us know.