Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
redirect if reffering page isn't..
Old 01-10-2006, 05:13 PM redirect if reffering page isn't..
Ultra Talker

Posts: 358
Location: Devon, UK
Trades: 4
This is probably a simple one...

I've got a php page which contains a form, I only want this form to be accessed if users have come from page1.php or page2.php, if they havn't come from these pages I want them to be redirected to page3.php.

Any ideas?

Thanks
Simon
recedo is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-10-2006, 05:20 PM
stOx's Avatar
Machine

Latest Blog Post:
Worlds Smallest Car - Peel P50
Posts: 2,111
Name: Matt. (>',')>
Location: London, England.
Trades: 0
You could check the referrer with $_SERVER['HTTP_REFERER'];

But some browsers and firewalls dont pass on the referrer, so it wouldnt work for everyone.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
stOx is offline
Reply With Quote
View Public Profile Visit stOx's homepage!
 
Old 01-10-2006, 05:33 PM
Ultra Talker

Posts: 358
Location: Devon, UK
Trades: 4
I really need something that would work for everyone, if possible.

The idea is that page 1 or 2 contains the first part of the form (depending on which is selected). Then part 2 of the form contains an upload applet, but before uploading we need to make sure we have the file info which is provided in page 1 or 2.

Most users would do this correctly, but I don't want people to bookmark the upload applet and then access it directly. Otherwise we will have no notification of new uploads, or the details.

Thanks for your help
Simon
recedo is offline
Reply With Quote
View Public Profile
 
Old 01-10-2006, 06:41 PM
TrentonD's Avatar
Ultra Talker

Posts: 253
Location: Calgary, Alberta, Canada
Trades: 0
I go about things like this using a hidden variable.

On your first form page, you would include a hidden variable like so:

HTML Code:
<input type="hidden" value="1" name="check_formsubmit">
And then, on the next page (the one you want to protect), you would have to do a check to see if this variable has been passed. But first, you would need to create that variable in PHP, like this:

PHP Code:
$check_formsubmit $_POST['check_formsubmit']; 
The part that checks if the form has been submitted would look like:

PHP Code:
if ($check_formsubmit == 1) {
*
Page code here*
}

else {
echo 
"You must complete the first part of our forum first! *link here*";

I hope this works for you, as I was pulling this all from my head, and I'm still relatively new with PHP. If you have any problems with this, I can check it against the code I use for this kind of thing.

Hope this helps!
__________________
Signature Coming Soon! :)
Please login or register to view this content. Registration is FREE
TrentonD is offline
Reply With Quote
View Public Profile Visit TrentonD's homepage!
 
Reply     « Reply to redirect if reffering page isn't..
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.13433 seconds with 12 queries