Sridhar_Rao
In the zone
I have a page say result.php, which must be displayed only after a visitor fills in a form (reg.php). Even if the user visits result.php by typing the url, he must be directed to the registration page (reg.php). I am using page referer ($referer = $_SERVER['HTTP_REFERER']; )to see if the user came via the registration page or not.
This code works fine, but there is a problem. In the result.php page there is form which uses <?php echo $_SERVER['PHP_SELF']; ?>" method="post" to reload the page. At this stage the page checks once again if it has come from the refrerer and sends the page back to the registration page.
To check this I am using this script in the head of the html PHP Code:
If the user visits result.php for the first time, script would check if $ok is set, if it is not, he is directed to reg.php. When the user fills in reg.php and is directed to result.php, the script checks $ok (which is not set) but is directed from the correct location, so $ok is set to 1 and the page loads normally.
when the page reloads via a form, the page checks if $ok is set (actually it has been set to 1) and the page should load normally. But this is not happening, it is getting directed back to reg.php.
What is wrong?
It is still not working
This code works fine, but there is a problem. In the result.php page there is form which uses <?php echo $_SERVER['PHP_SELF']; ?>" method="post" to reload the page. At this stage the page checks once again if it has come from the refrerer and sends the page back to the registration page.
To check this I am using this script in the head of the html PHP Code:
PHP:
<?php
if (!isset($ok)){
$referer = $_SERVER['HTTP_REFERER'];
if ($referer != 'reg.php'){
header('Location: reg.php');
}else{
$ok=1;
}
}
?>
If the user visits result.php for the first time, script would check if $ok is set, if it is not, he is directed to reg.php. When the user fills in reg.php and is directed to result.php, the script checks $ok (which is not set) but is directed from the correct location, so $ok is set to 1 and the page loads normally.
when the page reloads via a form, the page checks if $ok is set (actually it has been set to 1) and the page should load normally. But this is not happening, it is getting directed back to reg.php.
What is wrong?
It is still not working