Skip to content

Instantly share code, notes, and snippets.

@brucenorton
Last active September 25, 2017 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brucenorton/d03c6262a9451a6719f513c6d88a20c8 to your computer and use it in GitHub Desktop.
Save brucenorton/d03c6262a9451a6719f513c6d88a20c8 to your computer and use it in GitHub Desktop.
post for jasonette demo form.json
<?php
require_once '../../_includes/connect.php';
$userName = $_REQUEST["userName"];
$userEmail = $_REQUEST["userEmail"];
$lastSeries = $_REQUEST["lastSeries"];
//define table
$tbl = "users";//change to your table i.e. John_app
//write query
$query = "INSERT INTO $tbl (userName, userEmail, lastSeries) VALUES (?,?,?)";
//prepare statement, execute, store_result
if($insertStmt = $mysqli->prepare($query)){
$insertStmt->bind_param("sss", $userName, $userEmail, $lastSeries);
$insertStmt->execute();
$insertRows = $insertStmt->affected_rows;
}else{
echo("<br>Oops there was an error: $insertStmt->error");
echo("<br>$mysqli->error");
}
//if the info got inserted
if($insertRows > 0){
echo("<br>Thanks $userName we have saved your info: $userEmail.
<p>not really of course</p>");
}else{
echo("<br>Sorry, there was a problem saving your info.");
}
$insertStmt->close();
$mysqli->close();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment