Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. psuedo code:
  2.  
  3. func postData()//client
  4. {
  5. var yourData = getDataForRow();/* or however your data is stored, as long as you make it compatible with however the you want the db to store it */
  6. var xhttp = new XMLHttpRequest();//i forgot what its actually called, look it up
  7. xhttp.open("POST", "http://endpoint.for.your.database/post.php", true);/*the post url is whatever you want it to be as long as that script deals with actually putting it in a db*/
  8. xhttp.setRequestHeader("", "");//if you're sending json, set appropriate header
  9. xhttp.send(yourData);
  10. }
  11.  
  12. func receivePostedData()//server
  13. {
  14. $conn = new mysqli($servername, $username, $password, $dbname);
  15. // Check connection
  16. if ($conn->connect_error) {
  17. die("Connection failed: " . $conn->connect_error);
  18. }
  19.  
  20. $sql = ""; //your sql insert command
  21.  
  22. if ($conn->query($sql) === TRUE) {
  23. echo "New record created successfully";
  24. } else {
  25. echo "Error: " . $sql . "<br>" . $conn->error;
  26. }
  27.  
  28. $conn->close();
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement