ClioSport.net

Register a free account today to become a member!
Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

  • When you purchase through links on our site, we may earn an affiliate commission. Read more here.

PHP Code Help



  Pink & Blue 182, JDM DC2
Spent ages on this today and a bit stuck.

I have a very simple formula

FORM - PROCESS PAGE - EXIT PAGE

After submitting the form, the process page runs and emails me the contents and then loads the exit page.

I want to stop the EXIT and PROCESS pages being accessed directly - i.e. by a URL being passed around in an email.

When you open the EXIT or PROCESS pages manually then it should load the FORM up instead.

I think I need to do something with HTTP_REFERER's etc... but am lost for the code.

Can someone come to my help? This is in PHP please.

Thanks
 
  cock mobile.
I had this problem ages ago; I think I sorted it using sessions.

It was quite a complicate dissertation I did though, and I wanted it right.
 
  Pink & Blue 182, JDM DC2
This is for a customer who's exit pages are legal documents so needs to be right and reliable.

Any help or resources appreciated.
 
  cock mobile.
You could use sessions then, but it might be over complicated.

I did a booking system sort of thing, and I wanted users to logon; I used session with an include to make sure the user was logged on, despite what page they directly went to.

I think that would be too complicated for what you want.

Must be an easier way for what you want; can't think of the top of my head.

Maybe some sort of redirect in htaccess file might work.
 
  HyperAlloy Combat Chassis
Should be easy with a session. Just set a session variable on your form page and then check on the process and exit page to see if it's been set. If not, redirect to the form page.

Using http_ref would also work, but you could conceivably spoof this info to get directly to the process or exit page.

Don't have any code to hand, but google groups is always good for nuggets ;)
 
Could do as mentioned. Use a number in the session, say 1. Clear all session data and set the session value to 1 on the form page. This is then incremented on the email page to 2, then on the exit page it's increased to 3. Have checks on each of the pages that the session is the number it should be, otherwise redirect elsewhere.

That's it basically. But I'd also add loads of checking, validation etc into the script too to help prevent any kind of hijacking or whatever
 
  Pink & Blue 182, JDM DC2
Session variable stuff sounds good - just need the code guys! Come to my rescue!
 
  As father and son....
function hascompletedForm() {
if (isset($_SESSION['completedForm'])) {
return true;
} else {
return false;
}
}



<? if (hascompletedForm()) {

print("<a href=\"index.php?pg=auth&amp;act=doLogout\" target=\"frame_content\" class=\"nav_links\">Logout");

}
?>


ud need to set the completedForm variable to true when u hit submit; which youd do by having
$_SESSION['completedForm'] = true

From the mouth of a buddy of mine; with abit of adaptation for ur specific forms


the if statement needs an "else redirect" also
 
Give me a few mins, I'll slap some code up for you


<edit>Can't work it out in my head, will have it later on for ya when I can test the code out
 
Last edited:
  Titanium 182
as said above if you add this to your form page to set the session, then the 2nd bit of code to each subsequent page this should do the trick.

## form page ##

<?php
session_start();
$_SESSION["yourform"] = "go";
?>


## subsequent pages ##

<?php
if(isset($_SESSION[yourform]) && ($_SESSION[yourform] != "") {
// your next page here
} else {
// redirect to form
$url = "YOUR FORM URL";
echo "<script>document.location.href='$url';</script>\n";
}
?>


Hope that helps
Neil
 


Top