Need Help in PHP

I am a PHP beginner. Can anyone help me to correct this form validation code?

registrationp.php

if(empty($_POST[‘password’]))
{
$error=“enter your password”;
header(‘Location:registration.php?errors=’.$error. ’ ');
}

registration.php
<input type=“password” name=“password” id=“password” placeholder=“password”><?php echo $_GET[‘errors’]; ?>

Why, what’s wrong with it? Does it give you an error?

What error message(s) are you getting?

Or do you mean a problem you’re having by using both $_GET and $_POST?

Something else?

First of all, after every header with location you need to have exit.
Second, you don’t have to redirect on error. You need to redirect on success.

As the code looks right now you will just have a continuous redirect loop
(password is empty by default and will be unless you submit the form).
Here it is a simple example of how things should look like:

<?php

$error = false;

if( isset($_POST['password']) ) {
    if( empty($_POST['password']) ) {
        $error[] = 'Invalid password';
    } else {
        // do stuff
        header('Location: allDone.php');
        exit;
    }
}
?>
<form ... >
<?php
if( !empty($error) ) {
    echo '<p>' . implode('<br />', $error) . '</p>';
}
?>
I guess you don't have only the password field, you also have other fields.
<input .. > <input type="submit" ... />

</form>

I had corrected the above error. But now I have another error.

<?php

if(empty($_POST['emailid']))
{

header("Location:registration.php?error=enter your email id");
}
else{
$emailid=$_POST['emailid'];
}
if(empty($_POST['name']))
{

header("Location:registration.php?error1=enter your name");
}
else{
$name=$_POST['name'];
}
if(empty($_POST['age']))
{

header("Location:registration.php?error2=enter your age");
}
else{
$age=$_POST['age'];
}
if(empty($_POST['password']))
{
//header("Location:registration.php?error3=enter your password");
$error="enter the password";
header('Location:registration.php?errors='.$error.'');
}
else{
$password=$_POST['password'];
}

I couldn’t show all the error at ones. It shows me only one error (i.e) “enter the password”.
I think I did a minor error. Please guide me.

You didn’t understand my point.

IF( error ) { remain in this page and show the error }
ELSE { redirect to some success page }

If you redirect for each error you loose the POST
(you need to keep your form values so the user will not complete it again every time)

However, you current code is not bad EXCEPT it shows you the last error because you did not add the exit (like I said).
After the header('Location … ’ the code does not stop, it keeps going.

Hello Luca tall

Please try This code which are given below.

I Hope is Really help YOU…

<?PHP
if(isset($_POST['signup']))
{
if($_POST['password'] !== "")
{
//Do you Work
echo "Filed is Fill";
}
else {
echo "Filed is Not Fill";
}
}
?>
<form action=""  method="post">
<input type="password" name="password" >
<input type="submit" name="signup">
</form>