Problem with "Register and Login (User Account System)"
Posted: Fri Jun 17, 2011 10:12 pm
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.
Jon
Parse error: syntax error, unexpected $end in C:\xampp\htdocs\BETTERPHP\login.php on line 71Could someone please take a look at my code and tell me if there is an error in the code?
<?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>Thank you very much.
Jon