Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- header('Content-type: application/json');
- header('Access-Control-Allow-Origin: *');
- $server = "localhost";
- $username = "root";
- $password = "";
- $database = "jqueryex";
- $con = mysql_connect($server, $username, $password);
- if($con) { echo "Connected to database!"; }
- else { echo "Could not connect!"; }
- mysql_select_db($database, $con);
- $topost = file_get_contents('php://input');
- $thedata=json_decode($topost, true);
- print_r($thedata);
- $id = $thedata['id'];
- $name = $thedata['name'];
- $Address = $thedata['Address'];
- $sql = "INSERT INTO sample (id, name, Address) ";
- $sql .= "VALUES ($id, '$name', '$Address')";
- if (!mysql_query($sql, $con)) {
- die('Error: ' . mysql_error());
- } else {
- echo "Comment added";
- }
- mysql_close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement