View Full Version : Multiple page with same address
devil_vin
09-16-2007, 04:25 PM
Hi..guys!I have several pages which supposed to execute in sequential order,reserve.php,reserve2.php,reserve3.php,...How could I resolve them in same address as reserve.php and execute in proper order?Thanks...
thetestingsite
09-16-2007, 04:31 PM
Using includes probably or even a simple iframe.
devil_vin
09-16-2007, 04:56 PM
Let said I have a button in first page to link to later pages
<input name="continue" type="button" id="continue4" value="Continue" onclick="window.location='reserve2.php'">
how can I use include() at here?
thetestingsite
09-16-2007, 04:59 PM
if (isset($_POST['continue'])) {
include_once('reserve2.php');
}
Simply continue to use that code to include the next page. I Personally think your best bet would actually be to use an iframe or just combine the other files into reserve.php.
Hope this helps.
djr33
09-16-2007, 04:59 PM
Use a session.
<?php
session_start();
$_SESSION['n'] = @$_SESSION['n']+1;
include('reserve'.$_SESSION['n'].'.php');
?>
EDIT: posted at the same time. Either way could work. testingsite's option would give more control. Mine is simpler, if you really just want it to run a new page on each load, without any confirmation/control.
devil_vin
09-16-2007, 05:05 PM
Actually I want it to be executed in proper order so user can't simply type reserve2.php,it must go through it from the first page,reserve.php
djr33
09-16-2007, 05:07 PM
My code will do that, but start from reserve1.php.
devil_vin
09-16-2007, 05:16 PM
Oh..Thanks..how to reset the "n",every time I open reserve.php,its value keep growing and said that warning that failed to include('reserven.php')
thetestingsite
09-16-2007, 07:48 PM
On the last page, you may want to unset the session like so:
unset($_SESSION['n']);
Hope this helps.
devil_vin
09-17-2007, 02:02 PM
Let said I have 2 pages right now,reserve,reserve2.php,when session reset,why these 2 pages are combined into one page with first page topped by last page??
djr33
09-17-2007, 02:49 PM
Not sure. Sounds like an error. Do you have an example?
devil_vin
09-17-2007, 03:12 PM
No error shown.But first page is topped by second page.
Seond Page
http://img.photobucket.com/albums/v233/bluejayster/reserve2.jpg
First Page
http://img.photobucket.com/albums/v233/bluejayster/reserve.jpg
djr33
09-17-2007, 03:16 PM
"Topped by"? I don't really understand what you mean.
However, you may want to use another method entirely.
The methods we posted were designed to simply display pages, not interact.
With forms like that, you should have a much more specific system setup to send the data from one to the next.
Something more like what testingsite posted in the first place would make sense here.
if (isset($_POST['myvariable'])), then you would know that the form has been submitted and you should display the next page.
devil_vin
09-17-2007, 03:28 PM
Sorry.I mean topping,the second page appear on top of first page,I am thinking to use session to control all pages shared the same address(reserve.php) and the value selected in drop down menu and radio button also have further processing,like store into database.So is it session much better than include()?
djr33
09-17-2007, 03:36 PM
session and include are both used, for different reasons.
I'd suggest taking a step back and figuring out exactly what you want.
It seems to me that you want a site that will start on a certain page, then submit to a second page, then a third, etc.
As I said, the options we've given you so far just display the next page, and they don't relate to actual data submission.
With a system in which you have forms that matter, you will want error checking as well.
Having two pages would make a lot more sense than combining them into one, especially if this isn't an area of coding you have a lot of experience.
It IS possible to make them all be one page, but I would suggest a different approach in that case, using get variables (page.php?variable=value) to set which page you're using. You could do the same, though it would take a bit more work to get it to know which page should be used. In that case, you should check which post variables have been set.
devil_vin
09-17-2007, 03:56 PM
Ya.I want the data pass through several pages,any method for data submission?For now I don't understand that why pages are combined after I reset session.
djr33
09-17-2007, 04:25 PM
Have the form on a single page then submit to another page (action="next.php"). That next page can interpret the data.
I like this tutorial--
http://www.php-mysql-tutorial.com/php-tutorial/using-php-forms.php
As for why there are two instances of the page, I have no idea. The code I gave should be on a page by itself, then grab the other pages. What you describe could be from having the code I gave you ON one of the pages, so it loops and does it twice. That's all I can think of, really.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.