EchoFool Posted May 25, 2008 Share Posted May 25, 2008 For some unknown reason which I cannot figure out, when I hit my submit button the form won't run. It does go into the script but I think something relating to my function might be the cause but I need some expert to double check because I am unsure on where my mistake is. No error is outputted, just nothing happens upon Submit being pressed. Form: <form name="" method="POST" action="login.php" id="Form1"> <p align=center> <span class=blackBold> Username (20 characters max!) <input type="text" size="20" name="Username" value=""><br><br> Password (20 characters max!) <input type="password" size="20" name="Password" value=""><br><br> Re-Enter (20 characters max!) <input type="password2" size="20" name="Password" value=""><br><br> Email (Must be valid!) <input type="text" size="50" name="Email" value=""><br><br> Please Enter the Code you see! <img src="CaptchaSecurityImages.php"> <input id="security_code" name="security_code" type="text"><br><br> </span> <input type="image" name="Register" src="../images/dcregister.jpg" width="100" height="25"><br> </p> </form> Process code: <?php If(isset($_POST['Register'])){ //check email validity function checkEmail($Email) { if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $Email)) { return FALSE; } list($EmailName, $EmailDomain) = split("@",$Email); if(getmxrr($Domain, $MXHost)) { return TRUE; } else { if(fsockopen($Domain, 25, $errno, $errstr, 30)) { return TRUE; } else { return FALSE; } } } //check captcha input match If($_SESSION['security_code'] != $_POST['security_code'] || empty($_SESSION['security_code'])) { Header("location: Login.php?register&SecurityCodeError"); Die; } //check username $Username = mysql_real_escape_string($_POST['Username']); If(strlen($Username) > 20 OR strlen($Username)< 1 OR !(preg_match("/^\w+$/",$Username))){ Header("location: Login.php?register&UsernameError"); Die; } //check password $Password = mysql_real_escape_string($_POST['Password']); If(strlen($Password) > 20 OR strlen($Password) < 5 OR !(ctype_alnum($Password))){ Header("location: Login.php?register&PasswordError1"); Die; } //check re-entry of password $Password2 = mysql_real_escape_string($_POST['Password2']); If ($Password != $Password2) { Header("location: Login.php?register&PasswordError2"); Die; } //check string length of email $Email = mysql_real_escape_string($_POST['Email']); If(strlen($Email) > 50){ Header("location: Login.php?Register&EmailError"); Die; } //calls function to check email validity if(checkEmail($Email) == FALSE){ Header("location: Login.php?Register&EmailError"); Die; } //username exists check $CheckUsername = mysql_query("SELECT Username FROM `usertable` WHERE `Username` = '$Username'"); If (mysql_num_rows($CheckUsername)>0) { Header("location: Login.php?register&UsernameTakenError"); Die; } // email exists check $CheckEmail = mysql_query("SELECT Email FROM `usertable` WHERE `Email` = '$Email'"); If (mysql_num_rows($CheckEmail)>0) { Header("location: Login.php?register&EmailTakenError"); Die; } $IP = $_SERVER["REMOTE_ADDR"]; $Date = date("Y-m-d H:i:s",time()); $Password = md5($Password); $EmailCode = md5(uniqid(rand(), true)); $Query = "INSERT INTO `usertable` (Username,Password,Email,IP,RegisterDate,ActivateCode) Values ('$Username', '$Password', '$Email', '$Country', '$IP', '$Date', '$EmailCode')"; mysql_query($Query) or die(mysql_error()); Unset($_SESSION['security_code']); Header("location: Login.php?Register&Success"); } ?> Hope you can help me out. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/107143-solved-form-doesnt-process/ Share on other sites More sharing options...
pocobueno1388 Posted May 25, 2008 Share Posted May 25, 2008 My guess is your image input type isn't acting as a submit button, and that $_POST value isn't going through, which would give you a blank page because of the if statement returning false. Try this and see if you get the error message. <?php if (isset($_POST['Register'])){ //check email validity function checkEmail($Email) { if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $Email)) { return FALSE; } list($EmailName, $EmailDomain) = split("@",$Email); if(getmxrr($Domain, $MXHost)) { return TRUE; } else { if(fsockopen($Domain, 25, $errno, $errstr, 30)) { return TRUE; } else { return FALSE; } } } //check captcha input match If($_SESSION['security_code'] != $_POST['security_code'] || empty($_SESSION['security_code'])) { Header("location: Login.php?register&SecurityCodeError"); Die; } //check username $Username = mysql_real_escape_string($_POST['Username']); If(strlen($Username) > 20 OR strlen($Username)< 1 OR !(preg_match("/^\w+$/",$Username))){ Header("location: Login.php?register&UsernameError"); Die; } //check password $Password = mysql_real_escape_string($_POST['Password']); If(strlen($Password) > 20 OR strlen($Password) < 5 OR !(ctype_alnum($Password))){ Header("location: Login.php?register&PasswordError1"); Die; } //check re-entry of password $Password2 = mysql_real_escape_string($_POST['Password2']); If ($Password != $Password2) { Header("location: Login.php?register&PasswordError2"); Die; } //check string length of email $Email = mysql_real_escape_string($_POST['Email']); If(strlen($Email) > 50){ Header("location: Login.php?Register&EmailError"); Die; } //calls function to check email validity if(checkEmail($Email) == FALSE){ Header("location: Login.php?Register&EmailError"); Die; } //username exists check $CheckUsername = mysql_query("SELECT Username FROM `usertable` WHERE `Username` = '$Username'"); If (mysql_num_rows($CheckUsername)>0) { Header("location: Login.php?register&UsernameTakenError"); Die; } // email exists check $CheckEmail = mysql_query("SELECT Email FROM `usertable` WHERE `Email` = '$Email'"); If (mysql_num_rows($CheckEmail)>0) { Header("location: Login.php?register&EmailTakenError"); Die; } $IP = $_SERVER["REMOTE_ADDR"]; $Date = date("Y-m-d H:i:s",time()); $Password = md5($Password); $EmailCode = md5(uniqid(rand(), true)); $Query = "INSERT INTO `usertable` (Username,Password,Email,IP,RegisterDate,ActivateCode) Values ('$Username', '$Password', '$Email', '$Country', '$IP', '$Date', '$EmailCode')"; mysql_query($Query) or die(mysql_error()); Unset($_SESSION['security_code']); Header("location: Login.php?Register&Success"); } else { echo 'ERROR: No such variable as $_POST[register]'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/107143-solved-form-doesnt-process/#findComment-549315 Share on other sites More sharing options...
AndyB Posted May 25, 2008 Share Posted May 25, 2008 if (isset($_POST['Register'])){ should be if (isset($_POST['Register_x'])){ images as submit items return the x and y co-ordinates of where they were clicked Quote Link to comment https://forums.phpfreaks.com/topic/107143-solved-form-doesnt-process/#findComment-549321 Share on other sites More sharing options...
EchoFool Posted May 25, 2008 Author Share Posted May 25, 2008 Argh got it working now, used AndyB's suggestion. Thanks guys for the help! Quote Link to comment https://forums.phpfreaks.com/topic/107143-solved-form-doesnt-process/#findComment-549578 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.