php - trying insert a checkbox in a form of terms and condition -
i trying input check-box terms , conditions in form, when registered form without ticking box registration went through , (which not suppose be). please have look.
<?php echo "<h2>register</h2>"; $submit = $_post['register']; //form data $fullname = mysql_real_escape_string(htmlentities(strip_tags($_post['fullname']))); $username = strtolower(mysql_real_escape_string(htmlentities(strip_tags($_post['username'])))); $password = mysql_real_escape_string(htmlentities(strip_tags($_post['password']))); $repeatpassword = mysql_real_escape_string(htmlentities(strip_tags($_post['repeatpassword']))); $email = mysql_real_escape_string(htmlentities(strip_tags($_post['email']))); $houseno = mysql_real_escape_string(htmlentities(strip_tags($_post['houseno']))); $addressa = mysql_real_escape_string(htmlentities(strip_tags($_post['addressa']))); $addressb = mysql_real_escape_string(htmlentities(strip_tags($_post['addressb']))); $addressc = mysql_real_escape_string(htmlentities(strip_tags($_post['addressc']))); $county = mysql_real_escape_string(htmlentities(strip_tags($_post['county']))); $state = mysql_real_escape_string(htmlentities(strip_tags($_post['state']))); $country = mysql_real_escape_string(htmlentities(strip_tags($_post['country']))); $accept = mysql_real_escape_string(htmlentities(strip_tags($_post['accept']))); if ($submit) { $namecheck = mysql_query("select username reusers username='$username'"); $count = mysql_num_rows($namecheck); if($count!=0) { die("username taken!"); } //check registration form details if ($fullname&&$username&&$password&&$repeatpassword&&$email&&$houseno&&$addressa&&$county&&$state&&$country) { if($accept!= 1) { if ($password==$repeatpassword) { //check char lenght of username , fullname if (strlen($username)>25||strlen($fullname)>25) { echo "lenght of username or fullname long"; } else { //check password length if(strlen($password)>25||strlen($password)<6) { echo"password must between 6 , 25 characters"; } else { //check password length $emailcheck = mysql_query("select email reusers email='$email'"); $ecount = mysql_num_rows($emailcheck); if($ecount!=0) { echo"email registered please sign in account continue"; } else { //generate random code $code = rand(11111111,99999999); //send activation email $to = $email; $subject = "activate account"; $headers = "from: donotreply@reacheasy.co.uk"; $body = " hello $fullname,\n\nusername $username,\n\n password $password ,\n\nyou registered `and need activate account. click link below or paste url bar of browser\n\nhttp://reach.co.uk/activate.php?code=$code\n\nthanks!"; if (!mail($to,$subject,$body,$headers)) echo "we couldn't sign @ time. please try again later."; else { //register user! //encript password $password = md5($password); $repeatpassword = md5($repeatpassword); $queryreg = mysql_query(" insert reusers values ('','$fullname','$username','$password','$email','$code','0','houseno','addressa','addressb','addressc','county','state','country') "); die("you have been registered successfully! please check email ($email) activate account<a href='index.php'>return login page</a>"); } } } } } else echo"your passwords not match!"; } else echo"please read , accept terms , conditions before registering!"; } else echo "please fill in <b>all</> fields!"; } ?>
$accept = ($_post['accept'] ? 1:0);
Comments
Post a Comment