Jump to content

[SOLVED] Form doesn't process..


EchoFool

Recommended Posts

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!

Link to comment
Share on other sites

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]';
}

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.