Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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