Jump to content

Server Referer Issue


monkeybidz
 Share

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
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.

Link to comment
Share on other sites

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();
}

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • 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.