Jump to content

[SOLVED] username password check failing?!


dvd871

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.