Advertisement
payen83

JSON Post Data NEW

Dec 5th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. $name = $_POST['name'];
  5. $icNo = $_POST['icNo'];
  6. $company = $_POST['company'];
  7. $imageurl = $_POST['imageurl'];
  8.  
  9. $user = 'username';
  10. $password = 'password';
  11. $db = 'upm';
  12. $host = 'localhost';
  13.  
  14.  
  15. //open connection to mysql db
  16. $connection = mysqli_connect($host,$user,$password,$db) or die("Error " . mysqli_error($connection));
  17.  
  18. //fetch table rows from mysql db
  19. $sql = "INSERT INTO staff(name,icNo,company,imageurl) VALUES('$name','$icNo','$company', '$imageurl')";
  20. $result = mysqli_query($connection, $sql) or die("Error in Selecting " . mysqli_error($connection));
  21.  
  22. if ($result){
  23. $response["success"] = 1;
  24. $response["message"] = "User details saved";
  25.  
  26. } else {
  27. $response["success"] = 0;
  28. $response["message"] = "User details failed";
  29. }
  30. //echoing JSON response
  31. echo json_encode($response);
  32.  
  33. //close the db connection
  34. mysqli_close($connection);
  35.  
  36. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement