Hi guys, here is my problem it is driving me insane, though I am only new to PHP so it may be something simple.
I have a registration form with 4 text fields as follows:
Username
Password
Cpassword (confirm password)
Email
OK, here is the processing script, it is "supposed" to check top see if all of the fields have been entered, also if the username already exists, if the passwrod matches the cpassword, and that the email address is valid, then enter it into a database...
Here is the code(is long)...
<head>
<title>Register</title>
<link rel="stylesheet" href="/includes/war3pub.css" type="text/css">
<script language="JavaScript">
<!--
var time = null
function login() {
location.href='login.php'
}
function back() {
history.back
}
//-->
</script>
</head>
<?php
mysql_connect (localhost, war3pub, g1ngam9);
mysql_select_db (war3pub_maps);
if (ereg(".", $username) == 0)
{
echo "<body bgcolor="#000000" onload="timer=setTimeout('back()',3000)"><table width="100%" height="100%" border="0"><tr><td align="center" valign="middle"><div align="center"><b>Error: You must specify a username</b></div></td></tr></table></body>";
$verify = "bad";
}
else
{
$verify = "OK";
}
$result = mysql_query ("SELECT * FROM member
WHERE USERNAME = '$username'
");
if ($row = mysql_fetch_array($result))
{
print ("<body bgcolor="#000000" onload="timer=setTimeout('back()',3000)">");
print ("<table width="100%" height="100%" border="0">");
print ("<tr>");
print ("<td align="center" valign="middle">");
print ("<div align="center"><b>Error: The username ");
print ("$username");
print (" is already taken</b></div>");
print ("</td>");
print ("</tr>");
print ("</table>");
print ("</body>");
print ("");
$verify = "bad";
}
else
{
$verify = "OK";
}
if (ereg(".", $password) == 0)
{
print ("<body bgcolor="#000000" onload="timer=setTimeout('back()',3000)">");
print ("<table width="100%" height="100%" border="0">");
print ("<tr>");
print ("<td align="center" valign="middle">");
print ("<div align="center"><b>Error: Password is required</b></div>");
print ("</td>");
print ("</tr>");
print ("</table>");
print ("</body>");
print ("");
$verify = "bad";
}
else
{
$verify = "OK";
}
if $password != $cpassword
{
print ("<body bgcolor="#000000" onload="timer=setTimeout('back()',3000)">");
print ("<table width="100%" height="100%" border="0">");
print ("<tr>");
print ("<td align="center" valign="middle">");
print ("<div align="center"><b>Error: Password is not confirmed</b></div>");
print ("</td>");
print ("</tr>");
print ("</table>");
print ("</body>");
print ("");
$verify = "bad";
}
else
{
$verify = "OK";
}
if (ereg(".", $email) == 0)
{
print ("<body bgcolor="#000000" onload="timer=setTimeout('back()',3000)">");
print ("<table width="100%" height="100%" border="0">");
print ("<tr>");
print ("<td align="center" valign="middle">");
print ("<div align="center"><b>Error: You must specify an email address</b></div>");
print ("</td>");
print ("</tr>");
print ("</table>");
print ("</body>");
print ("");
$verify = "bad";
}
else
{
$verify = "OK";
}
if (!ereg('[-!#$%&\'+\./0-9=?A-Za-z{|}~]+'.
'@'.
'[-!#$%&\'*+\\/0-9=?A-Z^_a-z{|}~]+.'.
'[-!#$%&\'+\./0-9=?A-Z`a-z{|}~]+$', $last))
{
print ("<body bgcolor="#000000" onload="timer=setTimeout('back()',3000)">");
print ("<table width="100%" height="100%" border="0">");
print ("<tr>");
print ("<td align="center" valign="middle">");
print ("<div align="center"><b>Error: You must specify a valid email address</b></div>");
print ("</td>");
print ("</tr>");
print ("</table>");
print ("</body>");
print ("");
$verify = "bad";
}
else
{
$verify = "OK";
}
mysql_query ("INSERT INTO member (username, password, email)
VALUES ('$username', '$password', '$email')
");
print ("<body bgcolor="#000000" onload="timer=setTimeout('login()',3000)">");
print ("<table width="100%" height="100%" border="0">");
print ("<tr>");
print ("<td align="center" valign="middle">");
print ("<div align="center"><b>Thank you for registering </b></div>");
print ("$username");
print (", you will now be taken to the login page</b></div>");
print ("</td>");
print ("</tr>");
print ("</table>");
print ("</body>");
print ("");
?>
If anyone knows what is wrong with this code, it is popping up an error on line 29 to start with:
$verify = "bad";
The error is:
Parse error: parse error, expecting ','' or';''
So can anyone help please?