I have an error with a PHP register page I am creating.
<?php
$username = $_POST['username'];
$password = $_POST['password'];
if(isset($_POST['submit'])) {
if($username < 6 || $password < 6){
echo 'The username must be longer than 5 characters';
}
else {
$query = mysql_query("INSERT INTO users (username,password) VALUES ('".$username."',MD5('".$password."'))");
}
}
?>
<form method="post">
Username: <input type="text" name="username" maxlength="20" />
<BR>Password: <input type="password" name="password" maxlength="32" />
<BR><input type="submit" name="submit" />
</form>
Whenever I click on submit, even if the username and passwords are longer than 5 characters, it keeps saying the error message.
The page links to the database, but this is just the snippet that I am having trouble with.
Thanks
-Nicholas
You need to check if length of username and password is <6 and not $username