View Full Version : Why? :(

03-24-2010, 12:37 AM
For some reason the check_login.php page is just displayed blank, so it is running the script but ending somewhere it isnt ment to :/

Help please?


include "connect.php";

//Checks for error in connecting to database
if (!$con) {
$mess = "Error connecting to database! Error: ".mysql_error(); // Error connection to mysql database

$uname= $_POST['username'];
$pword= md5($_POST['password']);
$remMe= $_POST['rememberme'];

if ($uname == "" || $pword == "") {
$mess = "Invalid username or password!"; // No username has been entered
elseif (isset($_SESSION['username']) && isset($_SESSION['password'])) {
$mess = "You are already logged in!";
} else {
//Tests have been passed
mysql_select_db($dbname, $con);
$query=mysql_query("SELECT * FROM users");
if (!$query) {
$mess = "Unable to login! (Technical error)";

//Check if username and password matchs
while ($row=mysql_fetch_array($query)) {

if ($uname == $username && $pword == $password) {
// Username and password matches, make session variables

//Check is remember password has been set
if ($remMe==1) {
//Create cookies
setcookie("user", "$uname".md5($pword), time()+0*0*0*7);
//Now redirect to main page
echo "Woop!";
$mess = "Login successfull!";
} //END While

+Does the script look good?

03-24-2010, 01:12 AM
Changed question.

03-24-2010, 02:47 AM
Start with #2 from the forum guidelines (http://www.codingforums.com/postguide.htm):

2) Type in a subject that summarizes your question- A great way to turn off other members wanting to help you is to type an incomplete or silly subject for your post. Examples of poor subject titles include:

- "Help!"
- "I'm a newbie...be gentle"
- "How can I..."
- "Urgent...deadline tomorrow!"

The above subjects either have absolutely nothing to do with the question itself, or are grossly incomplete (ie: "How can I..."). When asking for help, enter a subject that summarizes your question, period! Don't use silly, incomplete, or "bait" subjects. Some examples of good titles are:

- "How do I round a number to 2 decimal places using JavaScript?"
- "What's the difference between require() and include() in PHP?"
- "Can someone suggest a good, free HTML editor?"

Then, note that a blank page usually indicates a syntax error or parse error and that your error reporting is turned off. A forum search will show you how to turn it on so you can get the error. With all of those header() functions, I'll bet it's going to be complaining about "headers already sent".