dvd871 Posted August 7, 2007 Share Posted August 7, 2007 This is killing me. I have used this code dozens of times in various scripts but now all of a sudden it fails. The simple form: <html> <head> <title><?=$config['game_name']?></title> <link href="style.css" rel="stylesheet" type="text/css"> </head> <body> <table style="width: 80%; text-align: left; margin-left: auto; margin-right: auto;"> <tr><td style="width: 50%;">About Your Game Name - Put a short description of your game here.</td> <td><form action="login.php" method="post"> Username: <input type="text" name="username"><br> Password: <input type="password" name="password"><br> <input type="submit" name="submit" value="Submit"></form></td></tr> <tr><td> </td><td><h3><a href="register.php">REGISTER NOW!</a></h3></td></tr></table> </body> </html> The login.php: <?php $err = ""; $username = stripslashes($_POST['username']); $password = stripslashes($_POST['password']); // Check both username and password were supplied if((!$username) || (!$password)) { $err.="Please enter ALL of the information! <br />"; include "error.php"; exit; } // Check for invalid character in the username elseif(!preg_match("/^[\\w-_]*[\\w-_]$/", $username)) { $err.="Your user name contains invalid characters"; include "error.php"; exit; } // Check for invalid character in password elseif(!preg_match("/^[\\w-_]*[\\w-_]$/", $password)) { $err.="Your password contains invalid characters"; include "error.php"; exit; } ?> I have verified that the username and password are set after setting the initial variables. The code barfs on the if((!$username) || (!$password)) { It keeps telling me "Please enter ALL of the information!" I am using php 4.4.7, mySQL 4, apache 1.3x Link to comment https://forums.phpfreaks.com/topic/63646-solved-username-password-check-failing/ Share on other sites More sharing options...
teng84 Posted August 7, 2007 Share Posted August 7, 2007 i dont know if theres an effect but try using if(empty($username) || empty($password)) { Link to comment https://forums.phpfreaks.com/topic/63646-solved-username-password-check-failing/#findComment-317146 Share on other sites More sharing options...
jscix Posted August 7, 2007 Share Posted August 7, 2007 Trying using if (strlen($username) < 1) || (strlen($password) < 1)); Link to comment https://forums.phpfreaks.com/topic/63646-solved-username-password-check-failing/#findComment-317147 Share on other sites More sharing options...
dvd871 Posted August 7, 2007 Author Share Posted August 7, 2007 Now I know the second suggestion should have worked since its checking to see if the string length is greater than 1 but its still is failing! --Edit: output of $username snd password right before the first check: #DEBUG: admin #DEBUG: password Link to comment https://forums.phpfreaks.com/topic/63646-solved-username-password-check-failing/#findComment-317157 Share on other sites More sharing options...
teng84 Posted August 7, 2007 Share Posted August 7, 2007 echo those variable to see if your working for something Link to comment https://forums.phpfreaks.com/topic/63646-solved-username-password-check-failing/#findComment-317162 Share on other sites More sharing options...
Fadion Posted August 7, 2007 Share Posted August 7, 2007 I tried the whole code at localhost and its working correctly. Logically theres no error at all. Link to comment https://forums.phpfreaks.com/topic/63646-solved-username-password-check-failing/#findComment-317165 Share on other sites More sharing options...
dvd871 Posted August 7, 2007 Author Share Posted August 7, 2007 Yea, it must have been something messed up in php. I reinstalled XAMPP and it works fine now. What a waste of an hour. Stuff like this only happen to you when you are under the gun and must complete something... Thanks for the quick replies. Link to comment https://forums.phpfreaks.com/topic/63646-solved-username-password-check-failing/#findComment-317177 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.