1

This line isn't working for me:

header("location:landing.php?id=md5($_REQUEST['user'])");

I need to pass the id variable. How do I do this?

0

6 Answers 6

11

Try

header('location:landing.php?id=' . md5($_REQUEST['user']));

The md5 function shouldn't be in the quotes.

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

Comments

4
$id = md5($_REQUEST['user']);
header("location: landing.php?id={$id}");

or

header("location: landing.php?id=" . md5($_REQUEST['user']));

The "md5" is being treated as a string in your current code, remove it from the quotes.

Comments

2
header("Location: landing.php?id=".md5($_REQUEST['user']));

Comments

2

Only variable can be parsed into double-quote (ex.: "$id"). Code need to be evaluate first and then you append the result to your string.

header('Location: landing.php?id=' . md5($_REQUEST['user']));

There was also a typo in the way you wrote the header, HTTP header name should starts with a capital letter and there is a space after the ":". I'm not 100% sure it needs to be exactly this way, but it's the standard way to do it.

Comments

0

in php string concateneate using . operator

It should be

header("location:landing.php?id=".md5($_REQUEST['user']));

Comments

0

!

Note: HTTP/1.1 requires an absolute URI as argument to » Location: including the scheme, hostname and absolute path, but some clients accept relative URIs. You can usually use $_SERVER['HTTP_HOST'], $_SERVER['PHP_SELF'] and dirname() to make an absolute URI from a relative one yourself:

Comments

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.