Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

insert records using jquery and php not working

jquery

This topic has been archived. This means that you cannot reply to this topic.
No replies to this topic

#1 mutago

mutago

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 478 posts

Posted 12 July 2015 - 12:56 PM

 

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
 

<!DOCTYPE html>
<html>
 <head>
<script src="jquery.js"></script>
 
 
// 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>
 
 </body>
</html>
 
<?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";
 
 
 
?>
 

 





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download