I recently went through the video tutorial for Register and Login (User Account System). Everything worked great up to the last of the tutorial when I began receiving this error.
[syntax=php]Parse error: syntax error, unexpected $end in C:\xampp\htdocs\BETTERPHP\login.php on line 71[/syntax]
Could someone please take a look at my code and tell me if there is an error in the code?
[syntax=php]<?php
include('core/init.inc.php');
$errors = array();
if (isset($_POST['username'], $_POST['password'])){
if (empty($_POST['username'])){
$errors[] = 'The username cannot be empty.';
}
if (empty($_POST['password'])){
$errors[] = 'The password cannot be empty.';
}
if (valid_credentials($_POST['username'], $_POST['password']) === false) {
$errors[] = 'Username / Password incorrect.';
}
if (empty($errors)){
$_SESSION['username'] = htmlentities($_POST['username']);
header('Location: protected.php');
die();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="ext/css/style.css" />
<title>Login</title>
</head>
<body>
<div>
<?php
if (empty($errors) === false){
?>
<ul>
<?php
foreach ($errors as $error){
echo "<li>{$error}</li>";
}
?>
</ul>
<?php
}else{
echo 'Need an Account? <a href="register.php">Register here</a>';
}
?>
</div>
<form action="" method="post">
<p>
<label for="username">Username:</label>
<input type="text" name="username" id="username" value="<?php if (isset($_POST['username'])) echo htmlentities($_POST['username']); ?>" />
</p>
<p>
<label for="password">Password:</label>
<input type="password" name="password" id="password" />
</p>
<p>
<input type="submit" value="Login" />
</p>
</form>
</body>
</html>[/syntax]
Thank you very much.
Jon
Problem with "Register and Login (User Account System)"
Re: Problem with "Register and Login (User Account System)"
add another } after the one on line 25...it should do it..
Re: Problem with "Register and Login (User Account System)"
this block
[syntax=php]if (isset($_POST['username'], $_POST['password'])){[/syntax]
does not have a closing }
[syntax=php]if (isset($_POST['username'], $_POST['password'])){[/syntax]
does not have a closing }
Re: Problem with "Register and Login (User Account System)"
kalipsso and jacek
Thank you both. It works like a charm!
Jon
Thank you both. It works like a charm!
Jon
Re: Problem with "Register and Login (User Account System)"
![Embarrassed :oops:](./images/smilies/icon_redface.gif)
![Wink ;)](./images/smilies/icon_e_wink.gif)
good news that you got it working though.