Can I pass a var inside of a location tag (inside PHP)?

All my code is working, except for this:

$code = "xxx";
$url = "https://xxxx.com/index.php?code=$code";
location("$url");

It just refreshes the page. I also tried:

header('location: https://xxxr.com/index.php?code=$code');

It works, but does NOT pass the var…

Help please!

header("Location: https://xxxr.com/index.php?code=" . $code);
exit();

though you should be able to do this and I don’t know if the above would even work???

header("Location: index.php?code=" . $code);
exit();

Which would be better

if (isset($_GET['code']) {
    echo $_GET['code'];
} 

Your first example was what I needed. Worked perfectly! Thanks very much! :smiley:

Sponsor our Newsletter | Privacy Policy | Terms of Service