View Single Post
Old 01-29-2022, 07:38 AM  
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,091
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.

.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote