SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Feb 2012
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to let User enter a Code and have it call a specific page.

    Basically I want a User to be able to enter a code they have been given and when submitted it will bring them to a specific page. There will eventually be a hundred or so of these codes/pages.



    Not even sure where to start??

  2. #2
    SitePoint Addict
    Join Date
    Apr 2011
    Posts
    265
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    You could store in database the code and page. The code in one table column, and the page associated to it in other column.
    Then, with $_GET you get the code from url, select row withthat code in database, get the page, and redirect with: header('Location: page_url');
    Free: Web Programming Courses HTML, CSS, Flash
    Web Programming: AJAX Course and PHP-MySQL Course video Lessons
    Good JavaScript and jQuery course for beginners

  3. #3
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Another way would be to maintain an array of elements.

    PHP Code:

    $redirects 
    = array( 
    "abc123"=>"this_page",
    "xyx890"=>"that_page",
    );

    $incoming "abc123"

    if( array_key_exists($incoming$redirects)){

    header("Location: /somefolder/" $redirects[$incoming] . ".php" );
    exit();


    Essentially the same thing as MarPlo suggests, but with the upside you do not have to query a database, but the downside you have to maintain an array by hand.

    The $redirects array could be kept in another file and included, especially useful if you have a subsequent places that need access to that array.

  4. #4
    SitePoint Member
    Join Date
    May 2008
    Location
    Bhubaneswar, India
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Start from Google perhaps!
    There are also too many sites offering code snippets. Search 'em down.

    Just Google - "Code Snippets"
    https://www.google.co.in/search?q=code+snippets


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
  •