jamesxg1 Posted April 7, 2009 Share Posted April 7, 2009 <?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> Quote Link to comment https://forums.phpfreaks.com/topic/152912-solved-my-registration-script-wont-work/ Share on other sites More sharing options...
jamesxg1 Posted April 7, 2009 Author Share Posted April 7, 2009 By the way yes i am awar there are a very large ammount of 16's in the <select> area but this is not finished yet. Quote Link to comment https://forums.phpfreaks.com/topic/152912-solved-my-registration-script-wont-work/#findComment-803057 Share on other sites More sharing options...
Maq Posted April 7, 2009 Share Posted April 7, 2009 Have you echoed out the post variables to make sure they all contain expected values? print_r($_POST); Quote Link to comment https://forums.phpfreaks.com/topic/152912-solved-my-registration-script-wont-work/#findComment-803058 Share on other sites More sharing options...
jamesxg1 Posted April 7, 2009 Author Share Posted April 7, 2009 No, give me a min and i shall Quote Link to comment https://forums.phpfreaks.com/topic/152912-solved-my-registration-script-wont-work/#findComment-803060 Share on other sites More sharing options...
jamesxg1 Posted April 7, 2009 Author Share Posted April 7, 2009 Have you echoed out the post variables to make sure they all contain expected values? print_r($_POST); Ok done, all $_POST's came back perfect now im really confused to see what is going wrong here :S Quote Link to comment https://forums.phpfreaks.com/topic/152912-solved-my-registration-script-wont-work/#findComment-803067 Share on other sites More sharing options...
Maq Posted April 7, 2009 Share Posted April 7, 2009 Then echo under each if statement and see what doesn't output. Quote Link to comment https://forums.phpfreaks.com/topic/152912-solved-my-registration-script-wont-work/#findComment-803070 Share on other sites More sharing options...
jamesxg1 Posted April 7, 2009 Author Share Posted April 7, 2009 Then echo under each if statement and see what doesn't output. Lol!!, my bad i put <?php get_code() ?> in a type="hidden" value and i forgot to put the 'print' in lol sorry people, many thanks for your help. Quote Link to comment https://forums.phpfreaks.com/topic/152912-solved-my-registration-script-wont-work/#findComment-803075 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.