Jump to content

Referrer URL


porzant

Recommended Posts

Hi.. May I know how and in which scenario are you using this " $_SERVER['HTTP_REFERER'] "..? if you have refer page then and then only you have value for it.. otherwise its empty...so check for that...Regards,Vijay

Link to comment
Share on other sites

Hi.. May I know how and in which scenario are you using this " $_SERVER['HTTP_REFERER'] "..? if you have refer page then and then only you have value for it.. otherwise its empty...so check for that...Regards,Vijay

Link to comment
Share on other sites

I'm trying to make a "form protection" thing, I want it only to add a record to an SQL database if the referring page was the one I made, not one somebody else made with the same action. So on the action page I want to do something like:IF ($_SERVER['HTTP_REFERER']=="myform.php"){// some code

Link to comment
Share on other sites

I have a form which adds records to a table, I want to make sure that the user came from my form on another page, so it will only add messages which I have formatted. So in normal language, I need:if(referrer_url == "mypage.php"){// some code to run.}

Link to comment
Share on other sites

It would probably be better to use sessions, to make sure they are logged in on your site. The referrer will be empty if the URL was manually typed or selected from a bookmark, or if the browser is going from https to http. I'm not sure if browsers will set the referrer when submitting a form or not, the referrer is optional for browsers and it's easy enough to fake it.

Link to comment
Share on other sites

On the page with the form you need to start a session and set a variable, like this:

<?phpsession_start();$_SESSION['from_thesite'] = true;?>

On the form processing page, you need to again start the session and then make sure the variable is set:

<?phpsession_start();if (isset($_SESSION['from_thesite'])){  //they came from the form page}else{  //they didn't}?>

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...