I have a file that sends information for forms. How would I go about redirecting someone if the go directly to the file.
I have a file that sends information for forms. How would I go about redirecting someone if the go directly to the file.
check the $_SERVER["HTTP_REFERER"], if it doesn't come from where you expect it to come from, redirect it
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 withPHP Code:if (isset($_POST['data']))
If anyone can see it, my post was meant for anyone who reads it. Don't take it personally or think I'm being condescending... :nuts:
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 Code: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 by Twinkie; 11-18-2008 at 11:11 PM.
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.
Don't get me wrong as I believe if and when I help someone I also help myself whereby whatever someone learns I also learn.
But I will also accept credits or reps if you really want to part with it.