Jump to content

set variable on the Index

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
bonty89

bonty89

    Newbie

  • Members
  • Pip
  • 1 posts
I wanna know how set variable on the Index.php file

eg: when user click to login
it should display like this
anywebsite.org/index.php?action=login

profile link
anywebsite.com/index.php?action=profile
search
anywebsite.com/index.php?action=search

how to write like that

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
There are a LOT of ways, all based on the HTML you are running. The simplest is to include that in your anchor.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
webcodez

webcodez

    Programmer

  • Members
  • PipPipPipPip
  • 149 posts
Not sure if I understood you well, but if you're talking about GET variables:

An example of setting a GET variable through url is as you said:
anywebsite.com/index.php?action=profile
which sets the GET variable 'action' equal to 'profile', which results in an equal code to:

$_GET['action'] = "profile";

In general it would be:

anypage.php?variable_name=variable_value

So say you want to set the action variable for your index, you could have a link like:

index.php?action=action_name

and a code like:

<?php
$action = $_GET['action']; //puts the action requested through url into $action variable
echo htmlspecialchars($action); //outputs the action requested
?>

Hope this is what you meant and if you've got any questions let me know.

Also, if this is what you're talking about, then I'd advice you to have a look at my tutorial about GET Variables - setting variables through url.