Автор: Renegade: Дата: 04.27.2010
Вот код моей регистрации на сайте:
require('./config.php');
//This code runs if the form has been submitted
if (isset($_POST['submit'])) {
//This makes sure they did not leave any fields blank
if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2'] | !$_POST['gender'] | !$_POST['email']) {
die('You did not complete all of the required fields go back');
}
// checks if the username is in use
if (!get_magic_quotes_gpc()) {
$_POST['username'] = addslashes($_POST['username']);
}
$usercheck = $_POST['username'];
$check = mysql_query("SELECT userid FROM login WHERE userid = '$usercheck'")
or die(mysql_error());
$check2 = mysql_num_rows($check);
//if the name exists it gives an error
if ($check2 != 0) {
die('Sorry, the username '.$_POST['username'].' is already in use.go back');
}
// this makes sure both passwords entered match
if ($_POST['pass'] != $_POST['pass2']) {
die('Your passwords did not match.go back ');
}
// here we encrypt the password and add slashes if needed
if (!get_magic_quotes_gpc()) {
$_POST['pass'] = addslashes($_POST['pass']);
$_POST['username'] = addslashes($_POST['username']);
}
// Email Check
$emailcheck = $_POST['email'];
$checkemail = mysql_query("SELECT email FROM login WHERE email = '$emailcheck'")
or die(mysql_error());
$check2email = mysql_num_rows($checkemail);
if ($check2email != 0) {
die('Sorry, the email '.$_POST['email'].' is already in use.go back');
}
// now we insert it into the database
$insert = "INSERT INTO login (userid, user_pass, email, sex)
VALUES ('".$_POST['username']."', '".$_POST['pass']."', '".$_POST['email']."', '".$_POST['gender']."')";
$add_member = mysql_query($insert);
?>
Registered
Thank you, you have registered - you may now login.Do you wan't to login?
}
else
{
?>
}
?>
Автор: : Дата: 01.01.1970