Jump to content

Server Referer Issue


monkeybidz

Recommended Posts

Im working on an issue that keeps sending the user to logge_in.php and never to post_new.php even if it is the referer. Here is the code I have wrote so far:

 


if($_SERVER['HTTP_REFERER'] =="post_new.php"){
$referer = "post_new.php";
}elseif($_SERVER['HTTP_REFERER'] =="logged_in.php"){
$referer = "logged_in.php";
}

header("Location: ".$referer." ");
exit();
}

 

Thanks in advance! :wtf:

Link to comment
https://forums.phpfreaks.com/topic/255534-server-referer-issue/
Share on other sites

If the referer is from a certain page I need it to return there after login, but my problem is that the register page on my site returns a success mesage on the same page and there is a login link on the header. If the user clicks on login, they are returned to the register page.

Yeah, that was a typo. It's supposed to be login.php. I kind of narrowed down the problem and realized that the code I posted is working, just not passing the var because it sits inside another "if(". Here is the entire code which is suposed to follow the $referer and start a session if the $email checks out ok.

 

if($_SERVER['HTTP_REFERER'] =="post_new.php"){ 
   $referer = "post_new.php";
}elseif($_SERVER['HTTP_REFERER'] =="login.php"){ 
  $referer = "logged_in.php";
}

$email=$_POST['email'];

$sql="SELECT * FROM users WHERE email='$email' ";
$result=mysql_query($sql);

$count=mysql_num_rows($result);

if($count == "1" && $referer != ""){
session_start();
  $_SESSION['email'] = $email;
  header("Location: ".$referer." "); //I am not getting $referer here
  exit();
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.