Register
Posted: Fri Jan 05, 2007 1:36 am
Hi,
My register script is not working it echo's You could not be registered due to a system error. We apologize for any inconvenience. I think it's around the query
but i've been trying for hours here is the code bellow. Thanks
My register script is not working it echo's You could not be registered due to a system error. We apologize for any inconvenience. I think it's around the query
Code: Select all
mysql_query ("INSERT INTO 'login' (`username`,`email`,`password`) VALUES ('$username','$email',SHA('$password'))");
}Code: Select all
<?php
////
// Connect to the Database
////
include_once ('./db_connect.php');
////
// Handle the form.
////
if (isset($_POST['submit'])) {
////
// Check for a username
////
if (eregi ('^[[]\.\'\-] {2,15}$', stripslashes(trim($_POST['username'])))) {
$username = FALSE;
echo '<p><font color="red" size="+2"> Please enter a username</font></p>';
}
////
// Check for a email
////
if (eregi ('^[[]][a-z0-9_\.\-]*@[a-z0-9\.\-]+\.[a-z]{2,4}$', stripslashes(trim($_POST['email'])))) {
$email = escape_data($_POST['email']);
} else {
$email = FALSE;
echo '<p><font color="red" size="+2"> Please enter a vaild email</font></p>';
}
////
// Check for password and match confirmed password
////
if (eregi ('^[[]]{4,20}$',stripslashes(trim($_POST['password1'])))){
if ($_POST['password1'] == $_POST['password2']) {
$password = escape_data($_POST['password1']);
}else{
$password = FALSE;
echo '<p><font color="red" size="+2">Your password did not match</font></p>';
}
if ($username && $email && $password) {
}
////
// Add the user
////
mysql_query ("INSERT INTO 'login' (`username`,`email`,`password`) VALUES ('$username','$email',SHA('$password'))");
}
////
// Thank you page
////
echo '<h3>Thank you for registering to the website. You can now log into the website.';
exit();
} else {
echo '<p><font color="red" size"+2">You could not be registered due to a system error. We apologize for any inconvenience.</font></p>';
}
mysql_close();
?>
<h1>Register</h1>
<form action="register.php" method="post">
<fieldset>
<p><b>Username:</b> <input type="text" name="username" size="15" maxlength="15" value="<?php if (isset($_POST['username'])) echo $_POST['username']; ?>" /></p>
<p><b>Email:</b> <input type="text" name="email" size="40" maxlength="40" value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>" /></p>
<p><b>Password:</b> <input type="password" name="password1" size="20" maxlength="20" /></p>
<p><b>Confirm Password:</b> <input type="password" name="password2" size="20" maxlength="20" /></p>
</feildset>
<div align="center"><input type="submit" name"submit" value="Register" /></div>
<input type="hidden" name="submit" value="TRUE" />
</form>