Hey,
I've got this form that allows people to register a username. Now it checks the database for exisiting usernames to make sure they can't register the same username twice but I keep getting a parse error on line 103 which is this line near the bottom:
} else {
Anyway, here is the code can you see anything? I've looked for hours now and I don't get what's wrong:
<?php
#open session#
session_save_path('/home/accessdata');
session_start();
if ($access_firstname=="") {
$title = '<img src="images/menu-notloggedin.png" width="135" height="18">';
} else {
$title = '<img src="images/menu-loggedin.png" width="135" height="18">';
}
if ($formsubmit!="") {
$formsubmit="";
#restrict access to members area
include ("/home/access/session.inc.php");
#db connection#
include("access/data.inc.php");
mysql_connect ($SQLhost, $SQLuser, $SQLpass);
mysql_select_db ($SQLdb);
#null error report.#
$error="";
#search for id#
$res_access = mysql_query ("SELECT id, username FROM table WHERE username='$username'");
$num_access = mysql_num_rows ($res_access);
if ($id=="") {
$error_field=1; $error.="Please enter your ID.<br>\n";
}
if ($name=="") {
$error_field=1; $error.="Please enter your Name.<br>\n";
}
if ($username=="") {
$error_field=1; $error.="Please enter a Username.<br>\n";
}
if ($email=="") {
$error_field=1; $error.="Please enter your Email Address.<br>\n";
}
if($error_field != 1) {
#Check email address validity#
if(!ereg("^[a-z0-9]+([^[:space:]]?[a-z0-9])+@[a-z0-9]+([-_.]?[a-z0-9])+.[a-z]{2,6}$",$email)) {
$error_field=1;
$error .= "Your email address is not valid, please try again.<br>\n";
} else {
$name = trim ($name);
$name = strtolower ($name);
$name = ucwords ($name);
$email = trim ($email);
$email = strtolower ($email);
#update db#
mysql_query ("INSERT INTO `table` (`id`, `username`) VALUES ('', '$username');")
or die ("<br><b>Please contact the webmaster, your account could not be made.</b><br>");
// LINE 61
$error_field=1;
$error.="Thank you for your query to register the username $username. We will get back to you shortly.<br>\n";
#send email#
$message = nl2br($message);
$message = preg_replace("/((http(s?):\/\/)|(www\.))([\S\.]+)\b/i",
"<a href=\"http$3://$4$5\"
target=\"_blank\">$2$4$5</a>", $message);
$message = preg_replace("/([w.]+)(@)([S.]+)b/i",
"<a href=%22mailto:$0/%22>$0</a>",
$message);
$From = "$name <$email>";
$support = "chris@yduk.net";
$subject = "Username Request";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: $From\r\n";
$message = "<html>
<head>
</head>
<body>
<p><b>Name </b><br>
$name</p>
<p><b>ID</b><br>
$id</p>
<p><b>Email address</b><br>
$email<br>
<br>
<b>Username required</b><br>
$username<br>
<br></p>
</body>
</html>";
mail($support, $subject, $message, $headers);
$sucess=1;
} else {
// LINE 106
#username already registered#
$error_field=1;
$error.="This username has already been registered. Please try another.<br>\n";
}
}
$form_complete="1";
}
?>