Jump to content

[SOLVED] Is this simple?


steviez

Recommended Posts

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

 

Link to comment
https://forums.phpfreaks.com/topic/40894-solved-is-this-simple/#findComment-198072
Share on other sites

<?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.

Link to comment
https://forums.phpfreaks.com/topic/40894-solved-is-this-simple/#findComment-198074
Share on other sites

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;
        }
?>

Link to comment
https://forums.phpfreaks.com/topic/40894-solved-is-this-simple/#findComment-198081
Share on other sites

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

 

Link to comment
https://forums.phpfreaks.com/topic/40894-solved-is-this-simple/#findComment-198100
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.