SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    masquerading Nick's Avatar
    Join Date
    Jun 2003
    Location
    East Coast
    Posts
    2,215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry password script not working

    Why won't this script work?

    Code:
    <?
        if (!($User=='Beo') && !($Pass=='test'))
        {
            echo 'You are not allowed to access this page.';
    		exit();
        }
    ?>
    You enter a name and pass through form page, and if they are the above you would be granted access to what the rest of the page contains, otherwise you would just get a blank page/ error message. Either way, right now, it gives access to the page, even with bad info.

  2. #2
    orange pips! orange pips!
    Join Date
    Oct 2001
    Location
    Its all about location
    Posts
    652
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Two things to try:

    1) Try changing your if statement to be:
    PHP Code:
    if (($User != 'Beo') && ($Pass != 'test')) 
    2) If that doesn't work, echo out what $User and $Pass are right before you do the if statement.

  3. #3
    masquerading Nick's Avatar
    Join Date
    Jun 2003
    Location
    East Coast
    Posts
    2,215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alright, I did both, the User and Pass and what has been entered into the form, but it still grants permission regardless.

  4. #4
    SitePoint Wizard
    Join Date
    Mar 2002
    Location
    Bristol, UK
    Posts
    2,240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What's with the brackets? Also it may make sense to use || instead of &&, which means OR as opposed to AND, which is what you're currently testing for. Try:
    PHP Code:
    if ($User != 'Beo' || $Pass != 'test'
    and see if that works.

    Hope this helps [img]images/smilies/smile.gif[/img]

    -Sam
    Sam Hastings

  5. #5
    orange pips! orange pips!
    Join Date
    Oct 2001
    Location
    Its all about location
    Posts
    652
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Possibility, are you hard coding the 'Beo' and 'test' into your script, or is that the values that are being pulled from the database? If they are being pulled from the database, then I would also suggest what Devilware said. I believed from what you posted the first time that you were hardcoing the values into your script to check against.

  6. #6
    masquerading Nick's Avatar
    Join Date
    Jun 2003
    Location
    East Coast
    Posts
    2,215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The values come from a form on another page. From action leads to this page.

    && or ||: But I want them to have to match, not an either or case...


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
  •