Click here to Skip to main content
15,886,088 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Insert records using Jquery and Php not working. This Jquery script below does not add content to database using php. can someone help me fix that.

Thanks


[CODE]


// API Here

  <script type="text/javascript">
   $(document).ready(function(){

$.post('database.php', {
    auid: environment.app_host.auid,
    user_auid: environment.user.user_auid,
    access_token: access_token


function(info){ $("#result").html(info);
   });

   });
  </script>
 </head>
 <body>


  <h3>Jquery data Submission in php</h3>
<div id="result"></div>
<br><br>



<?php
  // pdo connection
require('db.php');


   $x = $_POST['auid'];
  $y = $_POST['user_auid'];

  $z = $_POST['access_token'];



$statement = $db->prepare('INSERT INTO tb_API (data1,data2,data3) 
                          values
               (:data1,:data2,:data3)  ');
$statement->execute(array( 
':data1' => $x,
':data2' => $y,
':data3' => $z,
));
  

echo "Success";



?>
Posted
Comments
Dave Kreskowiak 12-Jul-15 20:22pm    
"Not working" is not a description of the problem. What DOES happen when you run the code? Any error messages?

1 solution

no error messages and the data could not be submitted
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900