redirect

djcustom

New Member
Messages
17
Reaction score
0
Points
0
I have a file that sends information for forms. How would I go about redirecting someone if the go directly to the file.
 

mephis

New Member
Messages
39
Reaction score
0
Points
0
check the $_SERVER["HTTP_REFERER"], if it doesn't come from where you expect it to come from, redirect it
 

Scoochi2

New Member
Messages
185
Reaction score
0
Points
0
Also, if they want directly to the file instead of using the forum, then no POST/GET data will be sent (although it is possible to send faux POST/GET data).
Check this with
PHP:
if (isset($_POST['data']))
 

Twinkie

Banned
Messages
1,389
Reaction score
12
Points
0
All great ways, but you could also use a PHP session if you want that extra bit of security, anyone can fake referrers or post data. Sessions let you keep variables specific to a user, stored in temporary files on the server and identified by session cookies that expire as soon as the browser closes.
PHP:
File:
<?php
session_start();
$_SESSION['IP']=$_SERVER['REMOTE_ADDR'];
?>

<html>
...

In Form:
<?php
session_start();
if ($_SESSION['IP']!=$_SERVER['REMOTE_ADDR'])
header('Location: http://www.yoursite.com/');
?>

<html>
...
 
Last edited:

dickey

New Member
Messages
128
Reaction score
0
Points
0
I agree with twinkie, curl can easily trick your page to make it believe that the referrer is legitimate I suggest you put a captcha and store the password in as a session variable and you will be sure of your security.

but basically you use the header() function to redirect in php.
 
Top