Help: Invalid url php help...

Discussion in 'PHP' started by Skillman13, Oct 26, 2009.

  1. #1
    I have some code,

    $number = urldecode( $_GET['id'] );

    Which gets the id from the url, ('/GAMETAB/template.php?&id=')

    but you can change this manually...

    to like '/GAMETAB/template.php?&id=200000'

    Which would be invalid.

    Is there any to put, if the 'id' number isnt in the table/database, it will redirect you to an error page, or something?

    Is this possible?

    Please comment...
     
    Skillman13, Oct 26, 2009 IP
  2. Keepern

    Keepern Peon

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    $number = urldecode( $_GET['id'] );

    Search $number in you database
    if ($number NOT found) {
    echo "Invalid";
    } else {

    ....

    Is this what you need or Im missing something here...?
     
    Keepern, Oct 26, 2009 IP
  3. Skillman13

    Skillman13 Peon

    Messages:
    229
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Perfect thanks.

    :)
     
    Skillman13, Oct 26, 2009 IP
  4. Skillman13

    Skillman13 Peon

    Messages:
    229
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Working :)
     
    Skillman13, Oct 26, 2009 IP
  5. mab

    mab Active Member

    Messages:
    563
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    80
    #5
    <?php
    // inval() is for security.
    $number = intval($_GET['id'])
    require_once(db_config.php);
    
    $queryGetGames = mysql_query("SELECT * FROM table_perfix WHERE id = '$number' ");
    $numGames = mysql_num_rows($queryGetGames);
    
    if($numGames == 0){
    echo "NO GAMES WERE FOUND";
    exit;
    }
    else{
    // your code here..
    }
    
    ?>
    
    Code (markup):
    Please notice that inval cannot deal with numbers bigger than 2147483647.
    Good Luck.
     
    mab, Oct 26, 2009 IP