php registrationform code
Posted: Tue Apr 14, 2015 1:37 pm
hi, i am trying to create a simple registration form with php, but i keep getting this error message :
"Parse error: syntax error, unexpected end of file in C:\Abyss Web Server\htdocs\register.php on line 113"
here is my code:
what is wrong with my code? if anyone can help, that would be great thankyou.
"Parse error: syntax error, unexpected end of file in C:\Abyss Web Server\htdocs\register.php on line 113"
here is my code:
Code: Select all
<!DOCTYPE html>
<?php
$page_title = 'Register';
include ('includes/header.html');
if($_SERVER['REQUEST_METHOD'] == 'POST') {
require ('C:\Abyss Web Server\htdocs\connect_db.php');
$errors = array();
if(empty($_POST['first_name'])) {
$errors [] = 'Enter your first name.';
} else {
$fn = mysqli_real_escape_string($dbc, trim($_POST[first_name]));
}
if(empty($_POST['last_name'])) {
$errors[] = 'Enter your last name.';
} else {
$ln = mysqli_real_escape_string($dbc, trim($_POST[last_name]));
}
if(empty($_POST [email])) {
$errors[] = 'Enter your email address.';
} else {
$e = mysqli_real_escape_string($dbc, trim($_POST[email]));
}
if(!empty($_POST[pass1])) {
if($_POST [pass1] != $_POST[pass2]) {
$errors[] = 'Passwords do not match';
} else {
$p = mysqli_real_escape_string($dbc, trim($_POST[pass1]));
}
} else {
$errors[] = 'Enter your password.';
}
if(empty($errors)) {
$q = "SELECT user_id FROM users WHERE email=$e";
$r = mysqli_query($dbc, $q);
if(mysqli_num_rows($r) != 0) {
$errors [] = 'Email address already registered.<a href="login.php">Login</a>';
}
}
if(empty($errors)) {
$q = "INSERT INTO users
(first_name,last_name,email,pass,reg_date)
VALUES($fn,$ln,$e,SHA1($P),NOW())";
$r = mysqli_query($dbc, $q);
if($r) {
echo '<h1>Registered!</h1>
<p> You are now registered.</p>
<p><a href="login.php">login</a></p>';
}
mysqli_close($dbc);
include (includes / footer . html);
exit();
} else {
echo'<h1>Error!</h1>
<p id="err_msg">The following error(s) have occured:<br>';
foreach($errors as $msg) {
echo "-$msg<br>";
}
echo 'Please try again.</p>';
mysqli_close($dbc);
}
?>
<h1>Register</h1>
<form action="register.php" method="POST">
<p>
First name:<input type="text" name="first name"
value="<?php if(isset($_POST['first_name']))
echo $_POST ['first_name'];
?>">
Last name:<input type="text" name="last name"
value="<?php if(isset($_POST[last_name]))
echo$_POST ['last_name'];
?>"></p>
<p>
Email address:<input type="text" name="email"
value="<?php if(isset($_POST['email']))
echo $_POST[email];
?>"></p>
<p>
Password:<input type="text" name="pass1"
value="<?php if(isset($_POST['pass1']))
echo $_POST['pass1'];
?>"></p>
Confirm Password:<input type="password" name="pass1"
value="<?php if(isset($_POST['pass2']))
echo $_POST['pass2'];
?>"></p>
<p><input type="submit" value="Register"></p>
</form>
<?php include ('footer.html'); ?>
</html>