PHP form validation not working as expected [dupli

2020-05-05 17:38发布

I'm a bit new to php and I was going over a tutorial where they are making validation form, but when I try and replicate what they do I don't get the same as them, when they run the code, the input box shows up red because the user hasn't placed anything in the input box. When I try it, nothing happens, the input box doesn't show me any errors.

But when I try and submit my form with data it just sends me to the next page, and if I dont type anything I just stay in the same page.

All this code is inside index.php

    if(($_POST['email']) != "")
    {
        header('Location:final.php');
    }
    else{
        $emailError = "validation";
    }

<form method="post" action="index.php" >

<!--Get warning here when no input is placed-->
<div class="<?=$emailError?>">
   <label>E-mail Address:</label>
   <input type="text" name="email">
</div>

0条回答
登录 后发表回答