Submit form from php script

  • Profile Image
    Asked on May 26, 2017 at 03:36 AM

    Hello, I have a php script that submits data to a form. It uses JotForm's php library and the function createFormSubmission.

    Here is the submission part of the code:

    $msg=array("q1_yourName","John Smith","q2_yourAge","42");

    $jotformAPI->createFormSubmission($formID, $msg);


    The problem is that the key in this array (as I understand it) - "q1_yourName" is ignored and the second element - "John Smith" gets in the first field of the form no matter what I put in the first one. Same with the "q2_yourAge".

    I can make the array look like this: ("some_random_text","John Smith","more_random_text","42") and I get the same result.

    Can someone please explain to me how form submission with php works? I ques I am just doing something wrong.

  • Profile Image
    Answered on May 26, 2017 at 04:40 AM


    Thank you for contacting us.

    You can submit data to your form using the JotForm API. Here is an example code:

      public function createFormSubmission($formID, $submission) {

            $sub = array();

            foreach ($submission as $key => $value) {

                if (strpos($key, '_')) {

                    $qid = substr($key, 0, strpos($key, '_'));

                    $type = substr($key, strpos($key, '_') + 1);

                    $sub["submission[{$qid}][{$type}]"] = $value;

                } else {

                    $sub["submission[{$key}]"] = $value;



            return $this->_executePostRequest("form/{$formID}/submissions", $sub);


    I have checked your form but I could not find a form with username and age fields. However, I can say that the q1_yourName and q2_yourAge part must unique ID of the field. Please check this fields unique IDs. Here is an  example:

    Also, if you are using "Full Name" field, you must send to data like:



    Also, here is a JotForm PHP API page on Github, you can check it:

    If you have questions about it, you can contact our API Team via this e-mail address: