Jump to content


Photo

If + Or? hmm login script not working?


  • Please log in to reply
3 replies to this topic

#1 AbydosGater

AbydosGater
  • Members
  • PipPipPip
  • Advanced Member
  • 435 posts
  • LocationAlways at computer!

Posted 30 September 2006 - 05:38 PM

Hi,
Ive been working on a login script, and the main bit is...

        <?php if($_POST['submit']){
if($username == $username2 && $password == $password2 | $username == $hackname && $password == $hackpass) {
session_register("username");
$_SESSION['username'] = $username;
echo "<font color=\"#FF0000\"><b>Thank you for login in,<br /> You will be redirected to the protected pages in 2 seconds <META HTTP-EQUIV=\"refresh\" CONTENT=\"2; URL=admin/index.php\"></b></font>";
}
} ?>

And it is pulling the USERNAME2 And PASSWORD2 and the hackname and hackpass from a config file, and i have tested it, and the variables are loading, now it worked before i added the hackname+pass variables to the if!

Ive been using | as an OR operator! is that correct? so its a login script but it has the two users, which are stored in another file, and now this was working before i added the second/"Hack" user, can anyone please help me?

Thanks
Abydos

www.abydosgaters.com

Current Project: Blog Application.. Undecided name.. Status: Coming along great.

#2 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 30 September 2006 - 05:50 PM

You need to use || for OR.

Orio.
Think you're smarty?

(Gone until 20 to November)

#3 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 30 September 2006 - 06:17 PM

You need to use || for OR.

Orio.


you also should get into the practice of grouping your conditionals for reading ease:
if(($username == $username2 && $password == $password2) || ($username == $hackname && $password == $hackpass)) {

You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#4 AbydosGater

AbydosGater
  • Members
  • PipPipPip
  • Advanced Member
  • 435 posts
  • LocationAlways at computer!

Posted 30 September 2006 - 08:51 PM

Oh Great THanks,
Fast reply! Thanks
www.abydosgaters.com

Current Project: Blog Application.. Undecided name.. Status: Coming along great.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users