Creating a registration form and am getting a parse error on the line in the html form code for email address?!
Any thoughts please.
Any thoughts please.
Code:
// Check for a first name:
if (empty($_POST['first_name'])) {
$errors[]='You forgot to enter your first name.';
} else {
$fn = trim($_POST['first_name']);
}
// Check for a last name:
if (empty($_POST['last_name'])) {
$errors[]='You forgot to enter your last name.';
} else {
$ln = trim($_POST['last_name']);
}
// Check for an email address:
if (empty($_POST['email'])) {
$errors[]='You forgot to enter your email address.';
} else {
$e = trim($_POST['email']);
}
// Check for a password and match against the confirmed password:
if (!empty($_POST['pass1'])) {
if ($_POST['pass1'] != $_POST['pass2']) {
$errors[]='Your password did not match the confirmed password.';
} else {
$p = trim($_POST['pass1']);
}
} else {
$errors[]='You forgot to enter your password.';
}
if (empty($errors)) { // If everything's OK.
// Register the user in the database...
// Make the query:
$q = "INSERT INTO users (first_name, last_name, email, pass, registration_date) VALUES ('$fn', '$ln', '$e', SHA1('$p'), NOW() )";
$r = @mysqli_query ($dbc, $q); // Run the query.
if ($r) { // If it ran OK.
// Print a message.
echo '<h1>Welcome</h1>
<p>You are now registered. Login and challenge!</p>';
} else { // If it did not run OK.
// Public message:
echo '</h1>System Error</h1>
<p class="error">You could not be registered due to a system error. We apologise for any inconvenience.</p>';
// Debugging message:
echo '<p>' . mysqli_error($dbc) . '<br /><br />Query: ' . $q . '</p>';
} // End of if ($r) IF.
// Include the footer and quit the script:
include ('includes/footer.html');
exit();
} else { // Report the errors.
echo '<h1>Error!</h1>
<p class="error">The following error(s) occurred:<br />';
foreach ($errors as $msg) { // Print each error.
echo " - $msg<br />\n";
}
echo '</p><p>Please try again.</p><p><br /></p>';
} // End of if (empty($errors)) IF.
mysqli_close($dbc); // Close the database connection.
} // End of the main Submit conditional.
?>
<h2><span style="color: #444444; font-weight: normal; letter-spacing: normal; font-size: 19px; line-height: 20px">Registration Form</span><br />
</h2>
<form action="registration.php" method="post" id="registrationform">
<p>Registration</p>
<p> <label for="first_name">First Name:</label> <input id="first_name" name="first_name" value="<?php if (isset($_POST['first_name'])) echo $_POST['first_name']; ?>" type="text" size="10" maxlength="20" tabindex="1" /></p>
<p> <label for="last_name">Last Name:</label> <input id="last_name" name="last_name" value="<?php if (isset($_POST['last_name'])) echo $_POST['last_name']; ?>" type="text" size="10" maxlength="20" tabindex="1" /></p>
<p> <label for="email">Email Address:</label> <input id="email" name="email" value="<? php if (isset($_POST['email'])) echo $_POST['email']; ?>" type="text" size="20" maxlength="40" tabindex="1" /></p>
<p> <label for="pass1">Password:</label> <input id="pass1" name="pass1" value="" type="password" size="10" maxlength="20" tabindex="1" /></p>
<p> <label for="pass2">Confirm Password:</label> <input id="pass2" name="pass2" value="" type="password" size="10" maxlength="20" tabindex="1" /></p>
<p class="no-border"><input class="button" type="submit" value="Submit" tabindex="5" /></p>
<input type="hidden" name="submitted" value="TRUE" />
</form>
Comment