The registration page:
<form method="post" action="adduser.php"
<table width="200" border="0" align="center" cellpadding="0" cellspacing="3">
<tr>
<td><div align="left">Name: </div></td>
<td><input type="text" name="name" maxlength="15"></td>
</tr>
<tr>
<td><div align="left">Username: </div></td>
<td><input type="text" name="user" maxlength="15"></td>
</tr>
<tr>
<td><div align="left">Password: </div></td>
<td><input name="pass" type="password" id="pass" maxlength="15"></td>
</tr>
<tr>
<td><div align="left">E-mail:</div></td>
<td><p>
<input name="email" type="text" id="email" maxlength="30">
</p>
</td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input name="Submit" type="submit" id="Submit" value="Submit">
<input type="reset" name="Reset" value="Reset">
</div></td>
</tr>
</table>
The php script:
<?PHP
if ((!$_POST['name']) || (!$_POST['user']) || (!$_POST['pass']) || (!$_POST['email']))
{
header("Location: http://www.domain.net/index.php?id=signup");
exit;
}
$dbaseuser = "domain_main";
$dbasepassword = "pw";
$dbasename = "domain_users";
$connection = mysql_connect("localhost", $dbaseuser, $dbasepassword)
or die(mysql_error());
$db = mysql_select_db($dbasename, $connection)
or die(mysql_error());
$sql = "INSERT into users (0, name, user, pass, email)
VALUES (0, '$_POST[name]', '$_POST[user], password('$_POST[pass]')), '$_POST[email]'";
$result = mysql_query($sql, $connection)
or die(mysql_error());
?>
HTML>
<HEAD>
<TITLE>Add a User</TITLE>
</HEAD>
<BODY>
Thank you,<? echo "$_POST[name]";?>. You have been successfully added to
the database. You may now <a href="www.domain.net/index.php?id=main">login</a>
.
<P>Name:<BR>
<? echo "$_POST[name]"; ?></p>
<P>Username:<BR>
<? echo "$_POST[user]"; ?></p>
<P>Password:<BR>
<? echo "$_POST[pass]"; ?></p>
<P>Email:<BR>
<? echo "$_POST[email]"; ?></p>
</BODY>
</HTML>
The error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '0, name, user, pass, email) VALUES (0, 'test', 'test, password('test')), 'tes' at line 1
In my users table i have my first field named 'id' which i made the primary and auto increments...that is why I put the 0 in the sql query which apparantly isn't correct. Any help would be deeply appreciated.