Parse error: syntax error, unexpected 'else' (T_ELSE) in C:\xampp\htdocs\tutorials\log in\register.php on line 33
After checking that I have matching "{" and "}"
still getting this error.
Is it because I'm escaping php before the form?
I have tried changing "else if" to "if" but then it I get warning that my variables are undeclared.
I have tried changing "else if" to "else" still get same warning.
The form is between the first and second php code blocks.
I have tried commenting out the form <!--- --->. That didn't help either.
Can someone please point out what I'm doing wrong here?
<?php
require 'core.inc.php';
if (!loggedin()){
if (isset ($_POST ['username'])&& isset ($_POST ['password'])&& isset ($_POST ['password_again'])&& isset ($_POST ['firstname'])&& isset ($_POST ['lastname']))
$username = $_POST ['username'];
$password = $_POST ['password'];
$password_again = $_POST ['password_again'];
$firstname = $_POST ['firstname'];
$lastname = $_POST ['lastname'];
if (!empty ($username)&& !empty ($password)&& !empty ($password_again)&& !empty ($firstname)&& !empty ($lastname))
echo 'OK';
} else {
echo 'All fields are required';
}
?>
<form action = "register.php" method = "POST" >
Username:<br> <input type = "text" name = "username"><br><br>
Password:<br> <input type = "password" name = "password"><br><br>
Password again:<br><input type = "password" name = "password_again"><br><br>
Firstname: <br><input type = "text" name = "firstname"><br><br>
Lastname: <br><input type = "text" name = "lastname"><br><br>
<input type = "submit" value = "Register">
</form>
<?php
else if (loggedin()) {
echo 'You\'re already registered and logged in.';
}
?>