steviez Posted March 2, 2007 Share Posted March 2, 2007 Hi, This maybe simple but im new to PHP so im :s If i want to have two or three pages in a PHP doc and access them like install.php?step1, install.php?step2 etc how do i do it? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/40894-solved-is-this-simple/ Share on other sites More sharing options...
Adika Posted March 2, 2007 Share Posted March 2, 2007 Hi! You can do this like this: <?php echo "<a href=\"install.php?step1\">Step1</a><br> <a href=\"install.php?step2\">Step2</a>"; ?> It is not complicated at all. All the best, Adika Quote Link to comment https://forums.phpfreaks.com/topic/40894-solved-is-this-simple/#findComment-198057 Share on other sites More sharing options...
steviez Posted March 2, 2007 Author Share Posted March 2, 2007 nooooo, i mean like if you have two complete pages in one php document and want to access them uising blaaa.php?page1 blaaa.php?page2 Quote Link to comment https://forums.phpfreaks.com/topic/40894-solved-is-this-simple/#findComment-198069 Share on other sites More sharing options...
Wuhtzu Posted March 2, 2007 Share Posted March 2, 2007 You can do something like this: <?PHP //Get the install step from the URL $step = $_GET['step']; //Creating the name of the actual file to be included $file = 'step' . $step . '.inc'; //Check that $step is set and that the file actually exists in your include dir if(isset($step) && file_exists('include/'.$file)){ include($file); } else{ include('step1.inc'); } ?> It will enable you to link like this: <a href="install.php?step=2>Step 2</a> and the file being displayed by following that link will be "step2.inc" which are placed in a folder called includes in the same folder as your install.php... Easy as that Quote Link to comment https://forums.phpfreaks.com/topic/40894-solved-is-this-simple/#findComment-198072 Share on other sites More sharing options...
idevlabsdotcom Posted March 2, 2007 Share Posted March 2, 2007 <?php //install.php $step = $_GET['step']; if($step == 1){ //include file here }elseif($step == 2){ //include file here }else{ //display default stuff here } ?> but your link would have to be: install.php?step=1 it's an oversimplification, but it should give you an idea of where to start. Quote Link to comment https://forums.phpfreaks.com/topic/40894-solved-is-this-simple/#findComment-198074 Share on other sites More sharing options...
Adika Posted March 2, 2007 Share Posted March 2, 2007 Hi! If you mean including, then do: <?php require "blaaa.php?page1"; require "blaaa.php?page2"; ?> Now, one php document will have these 2 pages included. Is this the answer you were looking for? All the best, Adika Quote Link to comment https://forums.phpfreaks.com/topic/40894-solved-is-this-simple/#findComment-198078 Share on other sites More sharing options...
boo_lolly Posted March 2, 2007 Share Posted March 2, 2007 to add to everyone elses post, i'd use a switch statement: <?php echo "<a href=\"index.php?step=1\">Step 1</a><br />\n"; echo "<a href=\"index.php?step=2\">Step 2</a><br />\n"; echo "<a href=\"index.php?step=3\">Step 3</a><br />\n"; switch($_GET['step']){ case '1': include "page1.php"; break; case '2': include "page2.php"; break; case '3': include "page3.php"; break; default: break; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/40894-solved-is-this-simple/#findComment-198081 Share on other sites More sharing options...
Adika Posted March 2, 2007 Share Posted March 2, 2007 Looks like everybody have some other way to this simple task. Well, I hope steviez will find the solution he was looking for! Quote Link to comment https://forums.phpfreaks.com/topic/40894-solved-is-this-simple/#findComment-198085 Share on other sites More sharing options...
Snooble Posted March 2, 2007 Share Posted March 2, 2007 Man, everyone's mental i swear. Steviez look up the GET command. It's very simple, Like you do with POST you enter the form fields name within parenthesis. $_GET['step']; would print what was entered in the field "step". For hyperlinking you wouldn't use this method. Snooble Quote Link to comment https://forums.phpfreaks.com/topic/40894-solved-is-this-simple/#findComment-198100 Share on other sites More sharing options...
steviez Posted March 2, 2007 Author Share Posted March 2, 2007 Thanks for all your help guys! Quote Link to comment https://forums.phpfreaks.com/topic/40894-solved-is-this-simple/#findComment-198101 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.