marmite Posted April 18, 2007 Share Posted April 18, 2007 Hello, I am trying to sort the login of a site I am reworking. However, even simply taking the current, working code of login.php off the server and using it on my local server doesn't work. So, I'm missing an extra file, or something. Can't find anything relevant in db.inc.php or .htacess, and don't know where else to look. So, there are two separate questions. The process in the code below seems to me that coming from login.php, the user should (if successful) be taken to myaccount.php. In fact, on the live site (www.cardsunlimited.com) this is not happening. That's question one: is the live site actually working as intended? The second and more important question is: how do I set $_POST['referer']? Is it set automatically? Because at the moment, it's blank. So, although I'm triggering the "If ($_POST)" statement, I am not triggering the "If ($_POST['referer'])=..." statements. $_SERVER['HTTP_REFERER'] is empty, and $_POST['referer'] is empty. Could it be that this simply doesn't work when the referer is localhost? Grateful for any help. I'm sure this is really simple, once you know how Emma <? error_reporting(0); require 'db.inc.php'; session_start(); if ($_POST) { // Check username and password echo "post"; echo $_SERVER['HTTP_REFERER']; $fu = $_POST['username']; $fp = $_POST['password']; $query = sprintf("SELECT * from users where username = '%s' and password = '%s'", mysql_real_escape_string($fu), mysql_real_escape_string($fp)); $result = mysql_query($query) or die("Error in query " . mysql_error()); $numrows = mysql_num_rows($result); if ($numrows > 0) { $row = mysql_fetch_assoc($result); $_SESSION['memberid'] = $row['user_id']; echo $_POST['referer']; if ($_POST['referer'] == "http://localhost/login.php") { header("Location: http://localhost/myaccount.php"); exit(); } if ($_POST['referer'] == "http://localhost/register.php") { header("Location: http://localhost/myaccount.php"); exit(); } else { header("Location: $_POST[referer]"); exit(); } } else { $error = "<span class='style1'>Invalid username/password combination</span>"; } } ?> Link to comment https://forums.phpfreaks.com/topic/47545-http_referer-issue/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.