0

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

4
  • you shouldn't ask for such syntax stuff. If you have any problem understanding something then post here. I will downvote it! and also give it a flag. So delete this post or modify so that it reflects the community's rules. Commented Jan 27, 2018 at 15:40
  • Why downvote it? I am literally asking for code help on a forum dedicated to helping people with codes. What is your problem? If you have an issue with my post then don't comment, leave. You're not welcome to post on my questions if you're only full of hate and negativity. Commented Jan 27, 2018 at 15:57
  • look, I didn't even downvote. To others, it was like inappropriate so they downvoted it. You should learn how to write, use basic functions in a language. Here we don't ask someone to write code for us, do we? And you are a new member of this wonderful community. So welcome. Commented Jan 27, 2018 at 16:04
  • I am not asking for you to write my code for me as I know most of the basic stuff anyway. I am asking for assistance, which is what this community is based around. Commented Jan 28, 2018 at 1:54

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Please, be aware that header('Location: ...') does not stop the script. You have to add a exit(0); after.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.