Professional Web Development Forums: PHP index.php?action=stuff

Jump to content

PHP index.php?action=stuff Bookmark

User is offline infestor1 

  • Banana King
  • Group: Members
  • Posts: 41
  • Joined: 10-January 09
  • Current Mood: Current Mood: None Chosen

Find Posts Tutorial info

  • Added on: 07 July 2009 - 10:35 PM
  • Views: 1,005
Okies!

My first tutorial here. It is teh very simple. We will be using get. Get is originally for forms (i think :P). But people have used it for other things because it displays the values in the url. Which means you can use the values in the URL as different pages. Just a couple if statements and you have a whole website, all on index.php! :P

So lets get started. I will show you the whole script then break it down into little pieces.:drool:






Okay lets break that down...


Begin the PHP code

$url = $_GET['action']; //get teh thing after action=

We get the value after index.php?action= and put that value into the variable $url

if($url == "admin") {

If that value we put in $url equals "admin", then...

echo "some admin stuff here";

We display the text "some admin stuff here"

}

Lets close the if statement.


if($url == "profile") {

echo "some profile stuff here";

}

if($url == "logout") {

echo "logout teh user";

}

if($url == "login") {

echo "display teh login form";

}


Lets use that method over and over until we have the desired amount of pages.


else {


If $url doesn't equal any of our set values, then....

echo "You r stupid because i cant find that page";

We display some angry text.

}

Lets close that else statement.

?>

We are now finished with our PHP script :woot:
0

Share:

Powered by (IM) Tutorials 1.1.0 © 2010, by Michael McCune

Enter your sign in name and password


Sign in options
  Or sign in with these services