-2

I have made a contact form in HTML5 and I would like to validate It with PHP. I used a method what was show by Brad Hussey in a UDEMY course. So I got the data with a POST method. Then comes this code:

if ($_POST) {

    if (!$_POST['nev']) {
        $error .= "Kérem töltse ki a név mezőt!<br>";
    }

    if (!$_POST['email']) {
        $error .= "Kérem adja meg az email címet!<br>";
    }

    if ($_POST['email'] && STfilter_var($_POST["email"], FILTER_VALIDATE_EMAIL) === false) {
        $error .= "A(z) $emailcim cím nem valós";
    } 

    if ($error != "") {
        $error ='<div class="alert alert-danger" role="alert">Hiba lépett fel!<br>' . $error . '</div>';
    } else {
        $nev = $_POST['nev'];
        $emailcim = $_POST['email'];

        include 'phpmailer.php';        
    }

}

The phpmailer.php works fine if I rune it alone. And If I skip the validation and go directly to phpmailer.php everything is okay. So the problem should be inside this 3 IF statements, just I can't figure It out :(

Do you have any idea?

update: Sorry I didn't write down well the problem. It is just simple white page. So when I click to the submit button, It doesn't send the mail, and not going back to the site. It became a totaly empty page. Something like when I miss a ; sign. But I checked It many times (with syntax checker too), and nothing is missing.

I think the problem could be somewhere here:

  if ($_POST['email'] && STfilter_var($_POST["email"], FILTER_VALIDATE_EMAIL) === false) {
    $error .= "A(z) $emailcim cím nem valós";
}

I don't really understand the working of this part.

1 Answers1

0

Tuğca Eker was right!

The problem was the STfilter_varprefix.

The correct statement is this:

if ($_POST['email'] && filter_var($_POST["email"], FILTER_VALIDATE_EMAIL) === false) {
$error .= "A(z) $emailcim cím nem valós"; 
}