Jump to content

Recommended Posts

<?php session_start();


error_reporting(E_ALL | E_NOTICE); 
error_reporting(E_ALL | E_STRICT);
error_reporting(E_ALL ^ E_NOTICE);

include 'Database/Connection.php';


$username        = mysql_real_escape_string($_POST['username']);                                                   
$username        = ereg_replace(" ", "", $username);    
$firstname       = mysql_real_escape_string($_POST['firstname']); 
$lastname        = mysql_real_escape_string($_POST['lastname']);                                                             
$email           = mysql_real_escape_string($_POST['email']);                                                            
$email           = ereg_replace(" ", "", $email);              
$password        = mysql_real_escape_string($_POST['password']); 
$confirmpassword = mysql_real_escape_string($_POST['confirmpassword']); 
$age             = mysql_real_escape_string($_POST['age']);
$address         = mysql_real_escape_string($_POST['address']);
$postcode        = mysql_real_escape_string($_POST['postcode']);
$userid          = mysql_real_escape_string($_POST['userid']);


$_SESSION['_username'] = mysql_real_escape_string($_POST['username']);
$_SESSION['_userid']   = mysql_real_escape_string($_POST['userid']);




if (isset($_POST['submit'])){
  
  if($username && $email && $password && $confirmpassword && $age && $address && $postcode && $userid){
$_name = "/^[-!#$%&\'*+\\.\/0-9=?A-Z^`{|}~]+";
$_host = "([-0-9A-Z]+\.)+";
$_tlds = "([0-9A-Z]){2,4}$/i";

if( !preg_match($_name."@".$_host.$_tlds,$email) ){
	echo "<div align=\"center\">The email you entered is of invalid format.</div>";
      	include("Register.php");
      	die();
}    

      if($password == $confirmpassword){
    

   
$sql="SELECT * FROM members WHERE username = '$username' AND userid = '$userid'"; 


    $secondsql="SELECT * FROM members WHERE email='$email'"; 
    
$result = mysql_query($sql);
    $secondresult = mysql_query($secondsql);
    

      if (mysql_num_rows($secondresult) > 0){

      
      echo "<div align=\"center\">The email you entered ($email) has already been registered.</div>";
      include("Register.php");
      die();
      }
            if (mysql_num_rows($result) > 0){
      
      echo "<div align=\"center\"><font color=#FF0000> <b><i>The username you entered ($username) is Not available.</i></b></font></div>";
      include("Register.php");
      die();
      }
     
      
      $password=md5($password);
  
	    	
	    $id = 1;
			$checkid="SELECT * FROM members WHERE id='$id'";
			$checkidresult = mysql_query($checkid);

			while(mysql_num_rows($checkidresult) > 0)
			{
				$id = $id + 1;
				$checkid="SELECT * FROM users WHERE id='$id'";
				$checkidresult = mysql_query($checkid);
			}	
  	

      mysql_query("INSERT INTO `members` ( `id` , `username` , `password` , `userid` , `firstname`, `lastname` , `age` , `address`, `postcode`, `email` )
   VALUES ('$id', '$username', '$password', '$userid', '$firstname', '$lastname', '$age', '$address', '$postcode', '$email');");

}else{
  echo "<font color=#FF0000> <b><i>Passwords don't match. Please try again.</i></b></font>";
  include("Register.php");
  die();
  }
  }else{

  echo "<div align=\"center\"><font color=#FF0000> 
  <b><i>You must fill out all the required fields!</i></b></font></div>";
  include("Register.php");
  die();
  }
}
include("Register.php");
?>

?>

 

Thats the actuall process script, all it keeps saying is i need to fill all the fields in but i have and it is still saying it :(

 

heres my registration form.

 

<?php session_start();


error_reporting(E_ALL | E_NOTICE); 
error_reporting(E_ALL | E_STRICT);
error_reporting(E_ALL ^ E_NOTICE);

include 'Database/Connection.php';

  $username = $_SESSION['_username'];

function get_code($seed_length= {
    $seed = "234567892345678923456789";
    $str = '';
    srand((double)microtime()*1000000);
    for ($i=0;$i<$seed_length;$i++) {
        $str .= substr ($seed, rand() % 48, 1);
    }
    return $str;
}

$unique = false;
do {
    $cap_code = get_code();
    
$query = sprintf("SELECT userid FROM `members`") or die(mysql_error()); 
$sql = mysql_query($query);

    if(mysql_num_rows($sql) == 0) {
        $unique = true;
    }
} while(!$unique);
?>
  
<html>
<head>
<title>Registration form</title>
<link href="css/style.css" rel="stylesheet" type="text/css">

</head>

<body>
<div align="center">
<div align="center">

  <form method="POST" action="SaveUser.php">
	<h3>Registration Form</h3>

<p><b>Username</b>
      <input type="text" name="username" size="20" value="<?php echo $username; ?>" maxlength="255">
    </p>
    <p><b>Email</b>
      <input name="email" size="20"  value="<?php echo $email; ?>" maxlength="255">
    </p>
    <p><b>First Name</b>
      <input name="firstname" size="20"  value="<?php echo $firstname; ?>" maxlength="255">
    </p>
    <p><b>Last Name</b>
      <input name="lastname" size="20"  value="<?php echo $lastname; ?>" maxlength="255">
    </p>
    <p><b>Password</b>
      <input type="password" name="password" size="20" maxlength="255">
    </p>
    <p><b>Confirm Password</b>
      <input type="password" name="confirmpassword" size="20" maxlength="255">
    </p>
<p>
 <b>Age:</b>

<select size="1" name="age" id="age">
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
<option value="16">16</option>
                </select>
 </p>
<p>
 <b>Address:</b><br><textarea rows="5" cols="40" name="address" id="$address"></textarea>
 </p>

<p>
 <b>Postcode:</b><br><input type="text" name="postcode" size="20" maxlength="255" />
 </p>

<p>
      <input type="hidden" name="userid" size="20" maxlength="255" value="<?php get_code() ?>">
    </p>

<p><img src="SecureSubmit.php"></p>

<p><b>Security Code:</b><br><input name="txtNumber" type="text" id="txtNumber" value="" /></p>

    <p align="center">
    <input type="submit" name="submit" value="Register" /> 
     <input type="reset" name="reset" value="Reset Form">
    </p>
<br>

Back to <a href="Login.php" >Login Page</a>
  </form>
  </div>
  <p> </p>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/152912-solved-my-registration-script-wont-work/
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.