You have an issue with your braces.
Look at
PHP Code:
if (strlen ($_POST['password1']) > 0) {
$password = TRUE;
} else {
$password = FALSE;
$message .= '<p>Your password did not match the confirmed password!</p>';
}
} else {
$password = FALSE;
$message .= '<p>You forgot to enter your password!</p>';
}
That section, and you'll notice that you have two closing braces before 'else'.
Change it to this:
PHP Code:
<?php # Script 3.13 - register.php
if (isset($_POST['submit'])) {
// validate the form
$message = NULL;
if(strlen($_POST['name']) > 0) {
$name = TRUE;
} else {
$name = FALSE;
$message .= '<p>You forgot to enter your name!</p>';
}
if (strlen($_POST['email']) > 0) {
$name = TRUE;
} else {
$name = FALSE;
$message .= '<p>You forgot to enter your email address!</p>';
}
if (strlen($_POST['username']) > 0) {
$username = TRUE;
} else {
$username = FALSE;
$message .= '<p>You forgot to enter your username!</p>';
}
if (strlen ($_POST['password1']) > 0) {
$password = TRUE;
} else {
$password = FALSE;
$message .= '<p>Your password did not match the confirmed password!</p>';
} else {
$password = FALSE;
$message .= '<p>You forgot to enter your password!</p>';
}
if ($name && $email && $username && $password) {
// If everything's okayOKs. Register the user.
// Send an email.
$body = "Thank you for registering with our site!\nYour username {$_POST['username']}'
and your password is '{$_POST['password1']}'.\n\nSincerely,\nAdministration";
mail($_POST['email'], 'Thank you for registering!', $body, 'From: [email]info@iwdtestsite.com[/email]');
header('Location: thankyou.php');
exit();
} else {
$message .= '<p>Please try again.</p>';
}
// Set the page title and include the HTML header.
$page_title = 'Register!';
include('./header.inc');
// Print the error message if there is one.
if (isset($message)) {
echo '<font color="red">', $message, '</font>';
}
?>
<form action"<?php echo $_SERVER['PHP_SELF']; ?> method="post">
<fieldset>
<legend>Enter your information in the form below (<font color="#FF0000">* Required</font>):</legend>
<p><b><font color="#FF0000">*</font>Name:</b>
<input type="text" name="name" size="20" maxlength="40" /></p>
<p><b><font color="#FF0000">*</font>Email Address:</b>
<input type="text" name="email" size="20" maxlength="60" />
</p>
<p><b><font color="#FF0000">*</font>User Name:</b>
<input type="text" name="username" size="20" maxlength="40" />
</p>
<p><b><font color="#FF0000">*</font>Password:</b>
<input type="password" name="password1" size="20" maxlength="40" />
</p>
<p><b><font color="#FF0000">*</font>Confirm Password:</b>
<input type="password" name="password2" size="20" maxlength="40" />
</p>
</fieldset>
<div align="center"><input type="submit" name="submit" value="Submit Information" /></div>
</form>
<?php
// Complete the conditional and PHP page.
// End of the main SUBMIT conditional
include ('./footer.inc');
?>
Bookmarks