Jump to content

A register page problem


zeeshan

Recommended Posts

hi i quite made a script like this but when i enter the data into it it says please enter a correct confirmation password by the way check it your selfs herewww.pokemoncratoz.zxq.net/register.phphere is the code please tell me where is the problem

<?phprequire_once 'db.php';$page_mode = isset($_POST['page_mode']) ? $_POST['page_mode'] : '';$error_string = '';if ($page_mode == 'register'){$username = $_POST['Username'];$email = trim($_POST['Email']);$password = $_POST['Password'];$Confirm_password = $_POST['Confirm_password'];if (!isValidEmail($email))$error_string .= 'Please enter a valid email address.<br>';if ($Username == '$Username')$error_string .= 'Please enter your username.<br>';if (strlen(trim($Password)) < 6)$error_string .= 'You must enter a password of at least 6 characters.<br>';if ($password != $Confirm_Password)$error_string .= 'The password and confirmation password do not match password.<br>';if ($error_string == ''){$result = db_query("SELECT id FROM user_info WHERE Username='" . mysql_real_escape_string($email) . "'");if (mysql_num_rows($result) > 0)$error_string .= 'That $Username username is already registerd.Please Select another one.<br>';else{$Username = mysql_real_escape_string($Username);$Email = mysql_real_escape_string($Email);$password = sha1($password);db_query("INSERT INTO user_info (Username, Email, Password,Trainer,Pokemon) VALUES ('$_POST[Email]', '$_POST[Username]','$_POST[Password]','$_POST[01]','$_POST[02]','$_POST[03]','$_POST[04]','$_POST[Bulbasaur]','$_POST[Charmendar]','$_POST[Squirtle]','$_POST[Pikachu]')");header('Location: thankyou.php');exit();}}}function isValidEmail($email = ''){return preg_match("/^[dw/+!=#|$?%{^&}*`'~-][dw/.+!=#|$?%{^&}*`'~-]*@[A-Z0-9][A-Z0-9.-]{1,61}[A-Z0-9].[A-Z]{2,6}$/ix",$email);}?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head><title>Register</title><style type="text/css">.error_text {color: #FF0000;width: 400px;text-align: center;}.left_box {float: left;width: 150px;text-align: right;padding-right: 5px;}.right_box {clear: right;}</style></head><body><div class="error_text"><?php echo $error_string; ?></div><form action="register.php" method="post"><input type="hidden" name="page_mode" value="register"><div class="left_box">Email address</div><div class="right_box"><input type="text" name="Email" size="40" maxlength="255" value="<?php if (isset($email)) echo $email; ?>"></div><div class="left_box">username</div><div class="right_box"><input type="text" name="Username" size="30" maxlength="255" value="<?php if (isset($Username)) echo $Username; ?>"></div><div class="left_box">Password</div><div class="right_box"><input type="password" name="Password" size="30"></div><div class="left_box">Confirm Password</div><div class="right_box"><input type="password" name="Conf_password" size="30"></div><h1>Please Select your trainer</h1><p>This is your Trainer Images</p><input type='radio' name='Trainer' value='01' ><img src="http://i304.photobucket.com/albums/nn178/pokemoncratoz/rstrainer00.png"/><input type='radio' name='Trainer' value='02' ><img src="http://i304.photobucket.com/albums/nn178/pokemoncratoz/rstrainer00.png"/<input type='radio' name='Trainer' value='03' ><img src="http://i304.photobucket.com/albums/nn178/pokemoncratoz/rstrainer00.png"/><input type='radio' name='Trainer' value='04' ><img src="http://i304.photobucket.com/albums/nn178/pokemoncratoz/rstrainer00.png"/><h1>Please Select your Pokemon.</h1><p>Hope it will surely help in your journey.</p><input type='radio' name='Pokemon' value='Bulbasaur' ><img src="http://i304.photobucket.com/albums/nn178/pokemoncratoz/Bulbasaur.png"/><input type='radio' name='Pokemon' value='Charmendar' ><img src="http://i304.photobucket.com/albums/nn178/pokemoncratoz/Charmander.png"/><input type='radio' name='Pokemon' value='Pikachu' ><img src="http://i304.photobucket.com/albums/nn178/pokemoncratoz/Pikachu.png"/><input type='radio' name='Pokemon' value='Squirtle' ><img src="http://i304.photobucket.com/albums/nn178/pokemoncratoz/squirtle.png"/><div class="left_box"> </div><div class="right_box"><input type="submit" value="Register" size="30"></div></form></body></html>

Link to comment
Share on other sites

$Confirm_password = $_POST['Confirm_password'];

You named your input field "Conf_password".

Link to comment
Share on other sites

so what should i change it into to make it perfect like this $conf_password= $_POST['conf_password'];
Or just change the input field.<div class="left_box">Confirm Password</div><div class="right_box"><input type="password" name="Confirm_password" size="30"></div>Anyways your site looks not bad.
Link to comment
Share on other sites

Unrelated to your issue, you really should design a "back" or "cancel" button on that page, so that people can get back to the main site without having to hit the back button. Not sure if you're finished designing yet or not, but that's usually something beginning designers forget to include.

Link to comment
Share on other sites

Sorry for the double post.i got this message from the page when i registered.Warning: preg_match() [function.preg-match]: Unknown modifier '+' in /www/zxq.net/p/o/k/pokemoncratoz/htdocs/register.php on line 47Please enter a valid email address.The password and confirmation password do not match.

Link to comment
Share on other sites

Well, your email regex is a little weird looking. The lowercase d and w in your first two sets of braces make no sense. Shouldn't they be escaped?Anyway, here's a site with some pretty good email regexes that I was just fooling around with. The ones with 5 green bars look pretty good.http://regexlib.com/DisplayPatterns.aspx?c...mp;categoryId=1

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...