Closed Thread
Results 1 to 3 of 3

Thread: set variable on the Index

  1. #1
    bonty89 is offline Newbie
    Join Date
    Mar 2010
    Posts
    1
    Rep Power
    0

    Thumbs up set variable on the Index

    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. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: set variable on the Index

    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

  4. #3
    webcodez's Avatar
    webcodez is offline Programmer
    Join Date
    Feb 2010
    Posts
    148
    Rep Power
    0

    Re: set variable on the Index

    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:

    Code:
    $_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:

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

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. using a variable as array index
    By jackson6612 in forum C and C++
    Replies: 4
    Last Post: 10-09-2011, 01:18 PM
  2. A-Z Index
    By jwg2s in forum PHP Development
    Replies: 2
    Last Post: 06-07-2011, 08:54 AM
  3. Replies: 3
    Last Post: 11-26-2010, 08:53 AM
  4. Replies: 7
    Last Post: 01-24-2010, 10:02 PM
  5. Replies: 1
    Last Post: 06-16-2009, 11:54 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts