My system goes like this: After registering in the MySQL database and a verification message is sent to an email, there is a link in that message that directs the user to a page called activate.php. Here comes the error:
<?php
$query = "SELECT active FROM users WHERE id='";
$query .= $_SESSION['id'];
$query .= "' LIMIT 1";
$result = mysqli_query($link, $query);
$row = mysqli_fetch_array($result);
if ( $row['active'] == 'false' ) {
$query = "UPDATE `users` SET `active`='true' WHERE `id`='";
$query .= $_SESSION['id'];
$query .= "' LIMIT 1";
$result = mysqli_query($link, $query);
**//THE END**
if ( $result ) header("diary.php");
else echo "<script type='text/javascript'>alert('Activation Failed! Server error!.');</script>";
} else {
header("diary.php");
}
?>
for the end section written as a comment,all of the previous code gets executed successfully and does update the table in the MySQL database. The rest of the code doesn't get executed at all and I always get an error message at the same time the code is executed. The error message is: Error message relating to a server error although some of the code gets executed
I really searched for that error a lot but nothing useful. I already made sure that the syntax has no errors.
Note: I've the link to the database working but didn't mention it for security issues.
Thanks in advance.
You wrote if ( $result ) header("diary.php"); else echo
there are semicolon before 'else' this is not correct
I found the bug. The header syntax should be as follows:
header("Location:diary.php");
Thanks everyone. It's now working great!