User Account System - not working
Posted: Mon Aug 20, 2012 10:09 pm
First off these are awesome tutorials.
Some reason my register.php is only saving the username and reloading that page with its value saved. I can't figure out why none of the errors come up.
Some reason my register.php is only saving the username and reloading that page with its value saved. I can't figure out why none of the errors come up.
<?php include('deep_down/init.inc.php'); $errors = array(); if (isset($_POST['username'], $_POST['password'], $POST['check_password'])) { if (empty($_POST['username'])) { $errors[] = 'You need a username.'; } if (empty($_POST['password']) || empty($_POST['check_password'])) { $errors[] = 'You need a password.'; } if ($_POST['passowrd'] !== $_POST['check_password']) { $errors[] = 'The passwords do not match.'; } if(user_exists($_POST['username'])) { $errors[] = 'The username is already taken.'; } if (empty($errors)) { add_user($_POST['username'], $_POST['password']); $_SESSION['username'] = htmlentities($_POST['username']); header('Location: home.php'); die(); } } ?> <html> <head> </head> <body> <p> <?php // display error messages if (empty($errors) === false) { ?> <ul> <?php foreach ($errors as $error) { echo"</li>($error)</li>"; } ?> </ul> <?php } ?> </p> <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> <label for="check_password">Check Password:</label> <input type="password" name="check_password" id="check_password"> </p> <p> <input type="submit" value="Submit" /> </form> </p> </div> </body> </html>Thanks for the help in advance : )