Re: Re: problem with my login script

From: Date: Tue, 02 Oct 2012 13:57:22 +0000
Subject: Re: Re: problem with my login script
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-319334@lists.php.net to get a copy of this message
To break or not to break? that's the question... All that fight makes me (and, I think that Thomas too) learn a bit more about all of this. And for finish with all of it. I think that if something is not deprecated, is because it's is a good idea to use it somewhere. If the Language developers think that way, i will not discord. Regards. Em 02-10-2012 10:35, Thomas Conrad escreveu:
My problem was solved no need to argue. I don't see why use a while loop with a count variable when it produces the same result as a foreach loop. As for using a break in the loop, I could add it but the loop is gonna stop anyway as soon as it hits the end of the array. I also didn't see the point in using the explode() function as long as I remove the (in my opinion) useless index numbers from the text file containing the username. The following code works as I expect it to: <?php session_start(); $users = file("../inc/users.inc.php"); if(!empty($_POST['username']) && !empty($_POST['password'])){ if(filter_var($_POST['username'], FILTER_VALIDATE_EMAIL)){ foreach($users as $row){ $row = trim($row); if($_POST['username'] == $row){ $_SESSION['logged_in'] = 1; $_SESSION['username'] = $row; } } if($_SESSION['logged_in'] != 1){ $error = "2"; } }else{ $error = "4"; } }else{ $error = "3"; } if($error){ header("Location:"); }else{ header("Location:"); } ?> users.inc.php: my@email1.com my@email2.com


« previous php.general (#319334) next »