Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jun 2005
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts

    What is happening, this should work.

    I have the following code in profile_add.php.

    PHP Code:
    $code=$_GET['c'];

    //check and see if propagated code is between 1-7 to prevent anything fishy
    if($code && ($code!=|| $code!=|| $code!=|| $code!=|| $code!=|| $code!=|| $code!=7))
    {
       die(
    'Invalid code. Please contact us if this problem persists.');

    When I access this page as "profile_add.php?c=7" it is constantly executing the die() function!

    How come?

  • #2
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Better way to do that.
    PHP Code:
    $code int($_GET['c']);

    if(
    $code == '0' || $code >7){
      die(
    'Invalid code. Please contact us if this problem persists.');


  • #3
    New Coder
    Join Date
    Jun 2005
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What is the int() in front of the GET command for?

    Will it convert anything?

  • #4
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Probably would be best to check if it's an integer instead of converting it I think.

    PHP Code:
    $code $_GET['c'];
    if(!
    is_int($_GET['c'])){
      die(
    "Must be a numerical value");
    }
    if(
    $code == '0' || $code >7){
      die(
    'Invalid code. Please contact us if this problem persists.');

    Basically, jsut checks to make sure the code is a numerical value and nothing else. Some people like to experiment with the urls to alter things and see what happens if they put text in a part that only meant to have numbers, etc.


  •  

    Posting Permissions

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