<?php
echo "<h1>Register</h1>";
$submit = $_POST['submit'];
//form data
$fullname = strip_tags($_POST['fullname']);
$username = strip_tags($_POST['username']);
$password = strip_tags($_POST['password']);
$repeatpassword = strip_tags($_POST['repeatpassword']);
$date = date("Y-m-d");
if ($submit)
{
//check for registration form details
if ($fullname&&$username&&$password&&$repeatpassword)
{
//encript password
$password = md5($password);
$repeatpassword = md5($repeatpassword);
if ($password==$repeatpassword)
{
//check char lenght of username and fullname
if (strlen($username)>25||strlen($fullname)>25)
{
echo "Lenght of username or fullname is too long";
}
else
{
//check password length
if(strlen($password)>25||strlen($password)<6)
{
echo"Password must be between 6 and 25 characters";
}
}else
{
//register the user!
echo "Success!!";
}
}
else
echo"Your passwords do not match!";
}
else
echo "Please fill in <b>all</> fields!";
}
?>
That’s why proper indentation is important.
<?php
echo "<h1>Register</h1>";
$submit = $_POST['submit'];
//form data
$fullname = strip_tags($_POST['fullname']);
$username = strip_tags($_POST['username']);
$password = strip_tags($_POST['password']);
$repeatpassword = strip_tags($_POST['repeatpassword']);
$date = date("Y-m-d");
if ($submit)
{
//check for registration form details
if ($fullname&&$username&&$password&&$repeatpassword)
{
//encript password
$password = md5($password);
$repeatpassword = md5($repeatpassword);
if ($password==$repeatpassword)
{
//check char lenght of username and fullname
if (strlen($username)>25||strlen($fullname)>25)
{
echo "Lenght of username or fullname is too long";
}
else
{
//check password length
if(strlen($password)>25||strlen($password)<6)
{
echo"Password must be between 6 and 25 characters";
}
}
else // <---- this else is giving the error (you can't have if ... else ... else ...)
{
//register the user!
echo "Success!!";
}
}
else echo"Your passwords do not match!";
}
else echo "Please fill in <b>all</> fields!";
}
?>
thanks, guido, please could you give a link to ow the if …else…else… should be structtured properly