In your “Error handlers section” you have a missing ) … empty($email
Often when you get an ‘unexpected …’ type of error that means that in the lines just before the line stated in the error message, there is a missing bracket, parentheses, brace or semi-colon.
When you follow a tutorial video, make sure you are not just blindly typing the code that is provided, but that you really understand every line of it and how it relates to the rest of the code, and what its purpose is. That way you are less likely to end up in a situation like this where you repeated an if-statement.
I am trying to do an email activation now and I have another file called activate.php but no information is passed on from the form action. I tried to do something liked this:
<?php
include_once 'dbh.php';
$uid = mysqli_real_escape_string($conn, $_POST['uid']);
$token = mysqli_real_escape_string($conn, $_POST['token']);
$sql = "SELECT * FROM users WHERE user_email='$uid' OR user_token='$token';";
$result = mysqli_query($conn, $sql);
$resultCheck = mysqli_num_rows($result);
if ($resultCheck > 0) {
while ($row = mysqli_fetch_assoc($result))
echo $row['user_token'];
}
but I got the following errors:
Notice: Undefined index: uid in C:\xampp\htdocs\loginsystem\includes\activate.php on line 7
Notice: Undefined index: token in C:\xampp\htdocs\loginsystem\includes\activate.php on line 8
The page is being called from another page with a form and the $uid input variable has not been selected and posted to the activate.php page. It is best to validate the post parameter instead of assuming the post variable has been passed.
I am still confused… I understand that the information has not been passed but does that mean that I can’t use $_POST? How would I do an email activation to set 1?
Also, I am also trying to add some extra line of codes here:
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
header("Location: ../signup.php?signup=email");
exit();
} else {
if (Strlen($password <= 5)) {
header("Location: ../signup.php?signup=invvalidlength");
exit();
}else {
$sql = "SELECT * FROM users WHERE user_uid='$uid'";
$result = mysqli_query($conn, $sql);
$resultCheck = mysqli_num_rows($result);
if($resultCheck > 0) {
header("Location: ../signup.php?signup=usertaken");
exit();
} else {
// Supply a random generated token for email activation
Remember what I said previously - if you get an 'unexpected … ’ error message, it means that there is either a missing closed bracket or brace, or a missing semi-colon . In other words, there is an unfinished statement before the else. So look at this if statement and see if you can see what is missing.
I found out the program… it was the way i put the {} but should i use preg_match and substr to check if the first character of a password is uppercase?