简体   繁体   中英

how to put php variable in header location?

my code is

<?php 
if(empty($_SESSION["adm_no"]))
{
    header("Location:<?php echo $homepage; ?jaxmas=wHgfghks^^%&fnjfskjdfb");
    
}
?>

I want to pass url through variable, but I am unable to get values from that variable.

You are putting php tags twice. Try this:

<?php 
if(empty($_SESSION["adm_no"]))
{
    header("Location:".$homepage."?jaxmas=wHgfghks^^%&fnjfskjdfb");
}
?>
<?php 
if(empty($_SESSION["adm_no"]))
{
    header("Location:".$homepage."?jaxmas=wHgfghks^^%&fnjfskjdfb");
}
?>

You don't need to open another php opening tags inside the opened one.

<?php 
  session_start();
if(empty($_SESSION["adm_no"]))
{
    header("Location:$homepage?jaxmas=wHgfghks^^%&fnjfskjdfb");

}
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM