Justin Humphries
Justin Humphries

Reputation: 43

PHP - if variable

Sorry I'm still really new to PHP but I was wondering if someone can give me a hand to get this to work? I'm a little confused

Something like

$name=htmlspecialchars($_POST['fname']);
$var2 = bad
if $name = $var2 redirect to error.html
else continue script

But I don't know the proper syntax. sorry if this is a stupid question

Upvotes: 0

Views: 46

Answers (1)

PrabhatSE
PrabhatSE

Reputation: 36

You can write your PHP code as below,

$name = htmlspecialchars($_POST['fname']);
$var2 = "bad";

if($name == $var2) {
    header("Location: error.html");
}

// here onwards you can do whatever you want to do

Hope this helps.

Upvotes: 2

Related Questions