<? If (isset($_POST['submit'])){ //This makes sure they did not leave any fields blank if(!$_POST['name'] | !$_POST['pass'] | !$_POST['pass2'] | !$_POST['mail']){ die ('تأكد من تعبئة الحقول'); } // checks if the username is in use $_POST['name'] = strip_tags($_POST['name']); $_POST['name'] = addslashes($_POST['name']); if (!get_magic_quotes_gpc()) {
function clean_entry($name) { $name = preg_replace('*([\s$+,/:=\?@"\'<>%{}|\\^~[\]`\r\n\t\x00-\x1f\x7f]|(?(?<!&)#|#(?![0-9]+;))|&(?!#[0-9]+;)|(?<!&#\d|&#\d{2}|&#\d{3}|&#\d{4}|&#\d{5});)*s' , '-' , strip_tags($name)) ; $name = trim(preg_replace('#-+#', '-', $name), '-'); return $name ; } } $usercheck = $_POST['name']; $usercheck2 = $_POST['mail']; $check = mysql_query("SELECT name , mail FROM log WHERE name = '$usercheck' and mail='$usercheck2'") or die(mysql_error());
$check2 = mysql_num_rows($check);
//if the name exists it gives an error if ($check2 !=0){ die('Sorry, the user name' .$_POST ['name']. ' '.$_POST ['mail'].'is already in use.');
} // this makes sure both passwords entered match if ($_POST['pass'] != $_POST['pass2']){ die ('Your passwords did not match. '); }
// here we encrypt the password and add slashes if needed $_POST['pass'] = md5($_POST['pass']); if (!get_magic_quotes_gpc()) { $_POST['pass'] = addslashes($_POST['pass']); $_POST['name'] = addslashes($_POST['name']); }
// now we insert it into the database $insert="INSERT into log(name,pass,mail) values ('".$_POST['name']."','".$_POST['pass']."','".$_POST['mail']."')"; $add_member = mysql_query($insert); ?> <h1>Registered</h1> <p>Thank you, you have registered - you may now login</a>.</p>