url navigation like index.php?id=1

By cooolstar on Jun 01, 2005

its for beginners.
world cooolstar Pakistan
cooolstar@gmail.com

<?
$phpself = $_SERVER['PHP_SELF']; //its you php page.
switch($_GET['id']) {
case '1':
print "hey buddy, you are on 1st id.<br> its a login page";
break;
case '2':
print "you are on the second id. <br> its a forum page";
break;
}
echo "<a href=$phpself?id=1>Login</a><br><a href=$phpself?id=2>forum</a>";
?>

Comments

Sign in to comment.
natar   -  Dec 22, 2010

Thanks for the descr code script sunslayer

 Respond  
sunslayer   -  Dec 21, 2010

@natar (assuming you've created the respective files)

<?php
    $phpself = $_SERVER['PHP_SELF']; //its you php page.
    switch($_GET['id']) {
        case '1':
            include("home.php");
            break;
        case '2':
            include("home_2.php");
            break;
    }
    echo "<a href=$phpself?id=1>Login</a><br><a href=$phpself?id=2>forum</a>";
?>
 Respond  
natar   -  Dec 20, 2010

I'm still a bit confusing, @hawkee could you write the full code for it? :(

 Respond  
Hawkee   -  Jun 01, 2005

Within each case statement you might want to include the code necessary to generate that page, for example:

case 1:
include(\'home.php\');
break;

This way the code doesn\'t get too confusing. It\'s also a good idea to handle form processing in a similar manner, for example:

$operator = $_POST[op];
switch($operator)
{
case \'save_data\':

 Respond  
chaplja   -  Jun 01, 2005

Thanks <3

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.