Hey i am trying to make a registration page for a pretend banking website for fun but when I try to load the script i keep on getting a error meassage saying
Parse error: syntax error, unexpected T_IF in C:\Program Files\EasyPHP-5.3.6.0\www\Bank website\Website pages\Bank register.php on line 75
I have no idea what it means by T_IF so im having troubles fixing it. I have check the code and it look fine to me but going to post anyways maybe i missed something thank for reading this and I hope this problem get solved. 🙂
<?php # Script 7.7 - register.php
$page_title = 'Register';
// Check if the form has been submitted.
if (isset($_POST['submitted'])) {
require_once ('/mysql_connect.php'); // Connect to the db.
// Create a function for escaping the data.
function escape_data ($data) {
global $dbc; // Need the connection.
if (ini_get('magic_quotes_gpc')) {
$data = stripslashes($data);
}
return mysql_real_escape_string(trim($data), $dbc);
} // End of function.
$errors = array(); // Initialize error array.
// Check for a first name.
if (empty($_POST['first_name'])) {
$errors[] = 'You forgot to enter your first name.';
} else {
$fn = escape_data($_POST['first_name']);
}
// Check for a last name.
if (empty($_POST['last_name'])) {
$errors[] = 'You forgot to enter your last name.';
} else {
$ln = escape_data($_POST['last_name']);
}
//Check for a country.
if (empty ($_Post['country'])) {
$erors[] = 'You forgot to enter a country.';
} else {
$country = escape_data($_POST['country']);
}
//Check for a provience
if (empty ($_Post['province'])) {
$erors[] = 'You forgot to enter a province.';
} else {
$province = escape_data($_POST['province']);
}
//Check for a city
if (empty ($_Post['city'])) {
$erors[] = 'You forgot to enter a city.';
} else {
$city = escape_data($_POST['city']);
}
// Check for an email address.
if (empty($_POST['email'])) {
$errors[] = 'You forgot to enter your email address.';
} else {
$e = escape_data($_POST['email']);
}
// Check for a PIN number.
if (empty($_POST['pin'])) {
$errors[] = 'You forgot to enter your PIN number.';
} else {
$pin = escape_data($_POST['pin']);
}
//make amount
$balance = 0
// Check for a password and match against the confirmed password.
if (!empty($_POST['password1'])) {
if ($_POST['password1'] != $_POST['password2']) {
$errors[] = 'Your password did not match the confirmed password.';
} else {
$p = escape_data($_POST['password1']);
}
} else {
$errors[] = 'You forgot to enter your password.';
}
if (empty($errors)) { // If everything's okay.
// Register the user in the database.
// Check for previous registration.
$query = "SELECT user_id FROM u WHERE email='$e'";
$result = mysql_query($query);
if (mysql_num_rows($result) == 0) {
// Make the query.
$query = "INSERT INTO users (first_name, last_name, country, provience, city, email, PIN, password, registration_date, balance) VALUES ('$fn', '$ln', '$country', '$provience', '$city', '$e', '$pin', SHA('$p'), NOW()), $balance";
$result = @mysql_query ($query); // Run the query.
if ($result) { // If it ran OK.
// Send an email, if desired.
// Print a message.
echo '<h1 id="mainhead">Thank you!</h1>
<p>You are now registered.You can now log in!</p><p><br /></p>';
// Include the footer and quit the script (to not show the form).
exit();
} else { // If it did not run OK.
echo '<h1 id="mainhead">System Error</h1>
<p class="error">You could not be registered due to a system error. We apologize for any inconvenience.</p>'; // Public message.
echo '<p>' . mysql_error() . '<br /><br />Query: ' . $query . '</p>'; // Debugging message.
exit();
}
} else { // Already registered.
echo '<h1 id="mainhead">Error!</h1>
<p class="error">The email address has already been registered.</p>';
}
} else { // Report the errors.
echo '<h1 id="mainhead">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.
mysql_close(); // Close the database connection.
} // End of the main Submit conditional.
?>
<html>
<html>
<p style="text-align:center">
<h2>Register</h2>
<form name="test" action="register.php" method="post" onsubmit= "return check_data(this)">
<p>First Name: <input type="text" name="first_name" size="15" maxlength="15" value="<?php if (isset($_POST['first_name'])) echo $_POST['first_name']; ?>" /></p>
<p>Last Name: <input type="text" name="last_name" size="15" maxlength="30" value="<?php if (isset($_POST['last_name'])) echo $_POST['last_name']; ?>" /></p>
<p>Country: <input type="text" name="country" size="15" maxlength="30" value="<?php if (isset($_POST['country'])) echo $_POST['country']; ?>" /></p>
<p>Province: <input type="text" name="province" size="15" maxlength="30" value="<?php if (isset($_POST['province'])) echo $_POST['province']; ?>" /></p>
<p>City <input type="text" name="city" size="15" maxlength="30" value="<?php if (isset($_POST['city'])) echo $_POST['city']; ?>" /></p>
<p>Email Address: <input type="text" name="email" size="20" maxlength="40" value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>" /> </p>
<p> PIN: <input type="password" name="pin" size="10" maxlength="4" /></p>
<p>Password: <input type="password" name="password1" size="10" maxlength="20" /></p>
<p>Confirm Password: <input type="password" name="password2" size="10" maxlength="20" /></p>
<p><input type="submit" name="submit" value="Register" /></p>
<input type="hidden" name="submitted" value="TRUE" />
</form>
</html>
</p>
The code on line 75 is :
// Check for a password and match against the confirmed password.
if (!empty($_POST['password1'])) {
if ($_POST['password1'] != $_POST['password2']) {
$errors[] = 'Your password did not match the confirmed password.';
} else {
$p = escape_data($_POST['password1']);
}
} else {
$errors[] = 'You forgot to enter your password.';
}
if (empty($errors)) { // If everything's okay.