Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- psuedo code:
- func postData()//client
- {
- 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 */
- var xhttp = new XMLHttpRequest();//i forgot what its actually called, look it up
- 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*/
- xhttp.setRequestHeader("", "");//if you're sending json, set appropriate header
- xhttp.send(yourData);
- }
- func receivePostedData()//server
- {
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = ""; //your sql insert command
- if ($conn->query($sql) === TRUE) {
- echo "New record created successfully";
- } else {
- echo "Error: " . $sql . "<br>" . $conn->error;
- }
- $conn->close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement