i want this to be happen user can not go directly to the page i have step by step booking i dont want this to be happen user can enter direct page on address bar if a user do this it gives error how can i do this....

these are the pages which i want that way

1 booking.php
2 checkstatus.php
3 ticketbook.php
4 ticketregistration.php
5 payment.php
6 printticket.php

these are thepages which i want to go that way i dont want user to go directly to print ticket by skipping information???how can i do this???

Recommended Answers

All 11 Replies

I would suggest using sessions to check what stage the user is at then make php exit the script with a message if the user has viewed a page in the wrong order. Below is an example:

<? session_start();
//page1.php

$_SESSION['pagestatus']=1;
?>
<a href='page2.php'>Next page</a>
<? session_start();
//page2.php
if ($_SESSION['pagestatus']!==1) {
    die('You have viewed the pages in the wrong order.');
    } else {
    $_SESSION['pagestatus']=2;
    }
?>
<a href='page3.php'>Next page</a>
<? session_start();
//page3.php
if ($_SESSION['pagestatus']!==2) {
    die('You have viewed the pages in the wrong order.');
    } else {
    $_SESSION['pagestatus']=3;
    }
?>
Final page
commented: thanx for the help +1

nice tips thanx man thanx for the help rep added thanx

another method without sessions
in each page, the 'refering page' of course is different

if ($_SERVER['HTTP_REFERER'] != 'referring page') {header("location: ./booking.php");}

The only problem with using referer page is that some browsers don't send that information to php making $_SERVER empty. This would mean that some users would find it impossible to browse the website. An example is the option in Opera where the user can choose if the browser should submit the referer information. So I find that it is best at all costs to avoid the $_SERVER variable unless you mix some javascript with it which in this case wouldn't be very secure.

The only problem with using referer page is that some browsers don't send that information to php making $_SERVER empty. This would mean that some users would find it impossible to browse the website. An example is the option in Opera where the user can choose if the browser should submit the referer information. So I find that it is best at all costs to avoid the $_SERVER variable unless you mix some javascript with it which in this case wouldn't be very secure.

All my forms submit to themselves, even those that take multiple submits to complete, the url does not change, you cant mess up referer, dont need sessions, cant be bypassed, now I know why my son suggested that.
I have added your post to my references, to make sure I dont again. - Thanks

I have residential rentals
my booking form, appl.php
outputs a different html page, dependant on the prior page's $_POST array. and the entire dataset is posted to the database and email notice sent at the end of the third form
m-hrt, you could use a single php page with multiple forms the url of the page never changes

All my forms submit to themselves, even those that take multiple submits to complete, the url does not change, you cant mess up referer, dont need sessions, cant be bypassed, now I know why my son suggested that.
I have added your post to my references, to make sure I dont again. - Thanks

I have residential rentals
my booking form, appl.php
outputs a different html page, dependant on the prior page's $_POST array. and the entire dataset is posted to the database and email notice sent at the end of the third form
m-hrt, you could use a single php page with multiple forms the url of the page never changes

I shall send I pic showing the option in Opera where you can disable the referer information which I would assume most other browsers do by default. A picture of the option in Opera is shown in the attachment to this post. Also you will find that if one browser can block the referer information then it is likely that some other browsers block it too.

I thanked and agreed with you, didnt need further proof

The second answer is a different approach without sessions there are always multiple methods that accomplish a desired result if (!$_post[] ( on page load display html form1 if (!$post['specific'] on submit with complete form1 post data display form 2 retain form 1 data else display form one with incomplete fields highlighted if (!$post['specific'] on submit with complete form 2 post data display form 3 retain form 1 2 esle display form 2 with incomplete fields highlighted if (!$post['specific'] on submit with complete form 3 update database, send confirmatory emails else display form 3 with incomplete fields highlighted

i want this to be happen user can not go directly to the page i have step by step booking i dont want this to be happen user can enter direct page on address bar if a user do this it gives error how can i do this....

these are the pages which i want that way

1 booking.php
2 checkstatus.php
3 ticketbook.php
4 ticketregistration.php
5 payment.php
6 printticket.php

these are thepages which i want to go that way i dont want user to go directly to print ticket by skipping information???how can i do this???

Hi,

Follow the Web structure, place it in WEB-INF

thanx guys for the help

ok. you can do one thing. Make a hidden field in all pages. and when user press the submit button of the particular page then set the value of the hidden field of the particular page as 1. check it on another page, if its 1 then do nothing otherwise redirect to the desired page. i Hope it will solve your issue. mail me if it works.

Thanks

Rahul
<EMAIL SNIPPED>

thanx rahul ill try this one too

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.