It looks to me like you have your ifs screwed up:
You have:
Quote:
if($stmt = mysqli_prepare($link, $sql))
{
// Bind variables to the prepared statement as parameters
// Attempt to execute the prepared statement
if(mysqli_stmt_execute($stmt))
{
// Close statement
mysqli_stmt_close($stmt);
}
// Records created successfully. Redirect to landing page
header("location: index.php");
exit();
}
else
{
echo "Oops! Something went wrong. Please try again later.";
}
|
You hit the redirect whether the insert worked properly or not. Your errror message is only if the prepare did not work.
Using what you have you would need something more like:
if($stmt = mysqli_prepare($link, $sql))
{
// Bind variables to the prepared statement as parameters
// Attempt to execute the prepared statement
if(mysqli_stmt_execute($stmt))
{
// Close statement
mysqli_stmt_close($stmt);
// Records created successfully. Redirect to landing page
header("location: index.php");
exit();
}
else
{
echo 'insert failed....';
}
}
else
{
echo "prepare failed";
}
I don't know that that is the only issue.
.