Multipage

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cyberlew15
Forum Newbie
Posts: 1
Joined: Fri Jul 26, 2002 5:13 pm
Location: United Kingdom

Multipage

Post by cyberlew15 »

I am used to using ASP but I cannot so I intend to use php my old code was

:roll:

<FONT COLOR="#000000" FACE="Verdana" SIZE=2>

<%
Dim Page
Page = request.form("Page")
If Page >< 1 And Page >< 2 And Page >< 3 Then Page = 1
Select Case Page
Case 1:%>
Page 1:<br><br>
<!--#include file="page1.txt"-->
<%
Case 2:%>
Page 2:<br><br>
<!--#include file="page2.txt"-->
<%
Case 3:%>
Page 3:<br><br>
<!--#include file="page3.txt"-->
<%
End Select

Select Case Page
Case 1: Response.Write ("<form method=POST action=index.asp>")
Response.Write ("<input type=submit style='width:75' value=Next name=Next>")
Response.Write ("<input type=hidden name=Page value=2>")
Response.Write ("</form>")

Case 2: Response.Write ("<form method=POST action=index.asp>")
Response.Write ("<input type=submit style='width:75' value=Previous name=Previous>")
Response.Write ("<input type=hidden name=Page value=1>")
Response.Write ("</form>")

Response.Write ("<form method=POST action=index.asp>")
Response.Write ("<input type=submit style='width:75' value=Next name=Next>")
Response.Write ("<input type=hidden name=Page value=3>")
Response.Write ("</form>")

Case 3: Response.Write ("<form method=POST action=index.asp>")
Response.Write ("<input type=submit style='width:75' value=Previous name=Previous>")
Response.Write ("<input type=hidden name=Page value=2>")
Response.Write ("</form>")
End Select
%>



Please help by posting a response with a link to code that I can download
samscripts
Forum Commoner
Posts: 57
Joined: Tue Apr 23, 2002 4:34 pm
Location: London, UK

Post by samscripts »

This should do the job, tho I haven't checked it myself.

edited because it didn't quite work - capitalisation problem

Try looking at http://www.php.net/manual/en/

http://www.php.net/manual/en/language.v ... ternal.php

http://www.php.net/echo
http://www.php.net/switch
http://www.php.net/isset

Welcome to php - kicks asp's butt :D

cheers, Sam

Code: Select all

<FONT COLOR="#000000" FACE="Verdana" SIZE=2> 

<?php 

// $page = isset($_POST&#1111;"page"]) ? $_POST&#1111;"page"] : 1; 
// above line changed to:

$page = isset($HTTP_POST_VARS&#1111;"Page"]) ? $HTTP_POST_VARS&#1111;"Page"] : 1;

/* 2 probs with previous line (before change): 1, $_POST&#1111;"page"] - the "page" should have been capitalised by me to match the form variable name, and 
2) changed $_POST to $HTTP_POST_VARS because it should always work
*/

if( $page != 1 && $page != 2 && $page != 3 ) $page = 1;

echo "Page $page:<br><br>";

// this include will give an error if the pages (page1.txt) etc are not in same folder as the script

include("./page$page.txt");



switch ($page)&#123;
	case 1:
?>
<form method=POST action=index.php> 
<input type=submit style='width:75' value=Next name=Next> 
<input type=hidden name=Page value=2> 
</form>
<?php
			break;
	case 2:
?>
<form method=POST action=index.php>
<input type=submit style='width:75' value=Previous name=Previous>
<input type=hidden name=Page value=1>
</form>

<form method=POST action=index.php>
<input type=submit style='width:75' value=Next name=Next>
<input type=hidden name=Page value=3>
</form>
<?php
			break;
	Case 3:
?>
<form method=POST action=index.php> 
<input type=submit style='width:75' value=Previous name=Previous>
<input type=hidden name=Page value=2> 
</form>
<?php

&#125;

?>
[/b]
Post Reply