hi everybody could you plase check my code whenever enter password i get the error message "password must be password must be betwwen 6/25"; anything wrong whit this code ?
<?php
$name=strip_tags( $_POST['fullname']);
$username=strip_tags( $_POST['username']);
$pass=$_POST['pass'];
$repass=$_POST['repass'];
$submit=$_POST['submit'];
$date=date("Y-m-d");
if(isset($submit))
{
if($name && $username && $pass && $repass)
{
$pass=md5($pass);
$repass=md5($repass);
if($pass=$repass)
{
if(strlen($name)>25 || strlen($repass)<6 )
{
echo "username or fullname are too long";
}
else
{
if(strlen($pass)>25 || strlen($pass)<6)
{
echo "password must be betwwen 6/25";
}
else
{
echo "ok";
//register
}
}
}
else
{
echo "passwords dont match";
}
}
echo "fill all the fields";
}
?>
<html>
<form action="register.php" method="post">
<table width="200" border="1">
<tr>
<td height="41">Full Name </td>
<td><label>
<input type="text" name="fullname" />
</label></td>
<td> </td>
</tr>
<tr>
<td><p>Choose</p>
<p> Nickname </p></td>
<td><label>
<input type="text" name="username" />
</label></td>
<td> </td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="pass" /></td>
<td> </td>
</tr>
<tr>
<td>RePassword</td>
<td><label>
<input type="password" name="repass" />
</label></td>
<td> </td>
</tr>
</table>
<br />
<input name="submit" type="submit" value="register" />
</form>
</html>
register form
Moderator: General Moderators
Re: register form
There's plenty wrong with that code. First, it's not between [ syntax=php] tags.
You never use the variable, so why are you initializing it?
You're using the assignment operator (=) when you want to be using a comparison operator (==).
This can't possibly be right. strlen($repass) will always be 32 because it has been md5 hashed. You probably meant strlen($username) > something.
You've already hashed the passwords, so the length will always be 32. Check the plain text passwords, then hash them. Also, don't use md5.
You shouldn't be using tables for layout, nor should you use deprecated, inline styling.
Code: Select all
$date = date("Y-m-d");Code: Select all
if ($pass = $repass)Code: Select all
if (strlen($name) > 25 || strlen($repass) < 6)
{
echo "username or fullname are too long";
}Code: Select all
if (strlen($pass) > 25 || strlen($pass) < 6)
{
echo "password must be betwwen 6/25";
}Code: Select all
<table width="200" border="1">Re: register form
thank you celauren it works now