3 Replies Latest reply on Jun 15, 2016 9:04 PM by sabar80419073

    How to post data into MySQL by JQM using PHP (Phonegap Build)?

    sabar80419073

      Petra Good Morning, Where are you?

      I want to show Result page when data submitted successfully to MySQL, but when I m doing like this It's removing client side validation. What i am doing wrong? with complain number. Thats randomly generated by math() function.

      Screenshot_1.png

      This posting code of JQuery Mobile.

      $("#postcomplaint").click( function() {

      $.post( $("#myForm").attr("action"),

               $("#myForm :input").serializeArray(),

               function(info){

        $( ":mobile-pagecontainer" ).pagecontainer( "load", "result.html", {transition:'flip' } );

         });

      clearInput();

      });

       

      $("#myForm").submit( function() {

        return false;

      });

      function clearInput() {

          $("#myForm :input").each( function() {

             $(this).val('');

          });

      }

      is that correct?

        • 1. Re: How to post data into MySQL by JQM using PHP (Phonegap Build)?
          kerrishotts Adobe Community Professional

          Please indicate what you're trying to accomplish, what you expect to happen, and what's actually failing. Mocking up a screenshot of what you expect to see would help, since otherwise I'm just guessing. (I'm assuming there should be a confirmation # up there?) It'd be nice to see the entire flow (from filling out the form, to submitting, to the expected and actual response).

           

          Also, since you're referring to PHP, we probably need to see your PHP code too.

          • 2. Re: How to post data into MySQL by JQM using PHP (Phonegap Build)?
            sabar80419073 Level 1

            Hi Kerrishotts,

            Thanks to response.

            Actually in Phonegap Build, Petra V. (Phonegap Build Champion), He knows all configuration of My App. But Unfortunately He is not here in new forum.

            BTW:

            I want to tell you something about my App:

            • It's my first Hybrid App with Phonegap Build.
            • I am not using Phonegap Desktop App, I am using Phonegap Build.
            • I am using PHP 7, MySQL 5.6 and JQM 1.4.5

            Now Here are few tasks remains:

            1. Posting data to MySQL using JQuery Post method.
            2. Creating a randomly generated unique Complaint Number (at the time of user will hire a complaint). I want to show this number to user in result.html page as shown above. (by this number user can check his/her complaint status anytime.)
            3. Now when I am trying to use this coding to post data in my Complaint table. To create 6 digits randomly unique number I am using mt_rand(100000,99999), but it's not inserting in table .

            postcomplaintinfo.php

            <?php

            $con = mysqli_connect("localhost","root","","amroclean");

            // Check connection

            if (mysqli_connect_errno())

              {

              echo "Failed to connect to MySQL: " . mysqli_connect_error();

              }

            $personname=$_POST['personname'];

            $emailphn=$_POST['emailphn'];

            $locationtxt=$_POST['locationtxt'];

            $latlon=$_POST['latlon'];

            $complaintlist=$_POST['complaintlist'];

            $otherdescription=$_POST['otherdescription'];

            $smallImage=$_POST['smallImage'];

            $complainno=mt_rand(100000,999999);

            mysqli_query($con,"INSERT INTO `complaint` (`peresonname`,`emailphn`,`locationtxt`,`compltypeid`,`otherdescription`,`image`,`complai nno`) values('$personname','$emailphn','$locationtxt','$complaintlist','$otherdescription','$sm allImage','$complainno')");

            if($con)

            echo "Successfully Inserted";

            else

            echo "Insertion Failed";

            ?>

            This is form:

            Screenshot_10.png

            Here is jquery mobile script:

            $("#postcomplaint").click( function() {

            $.post( $("#myForm").attr("action"),

                     $("#myForm :input").serializeArray(),

                     function(info){ alert("Data Posted Successfully!");

               });

            clearInput();

            });

             

            $("#myForm").submit( function() {

              return false;

            });

            function clearInput() {

                $("#myForm :input").each( function() {

                   $(this).val('');

                });

            }

            Now instead of highlighted alert i want that result page with unique number, for this what i do? Please help Kerrishotts.

            Thanks

            • 3. Re: How to post data into MySQL by JQM using PHP (Phonegap Build)?
              sabar80419073 Level 1

              The Complain no, is showing at the time of posting only, at editor it's not showing whitespace.Thanks

              And also I have solved the randomly generated numbers, now just facing the problem of jquery mobile page, When I am trying to load an external page of JQM as result, it's removing client side validation script.