Page 1 of 1

Simple error, overlooking it.

Posted: Thu Oct 16, 2003 7:20 pm
by Seifer
Here is my code for plogin.php (process login):

Code: Select all

<?php
$dbname = "random";
$dbpass = "random";
$db = "random";
$uname = $_POST['uname'];
$pword = $_POST['pword'];
$link = mysql_connect(localhost, $dbname, $dbpass);
$sdb = mysql_select_db($db, $link);
$result = mysql_query("SELECT uid FROM users WHERE uname = '$uname' AND pword = '$pword'");
if(mysql_num_rows($result) == 1){
	header(Location:"http://seifer.travisbsd.org/");
} else {
	echo "Bad username / password.";
}
?>
When I take out the header it runs fine but I substitute the header for an echo "You are now logged in, $username!". When I put the header in, it makes plogin.php a blank page..Thanks for any future replies.

Posted: Thu Oct 16, 2003 7:33 pm
by sinewave

Code: Select all

<?php
 header(Location:"http://seifer.travisbsd.org/");
?>
Should be

Code: Select all

<?php
 header("Location:http://seifer.travisbsd.org/");
?>

Posted: Thu Oct 16, 2003 7:34 pm
by Seifer
Still didn't redirect it.

Posted: Thu Oct 16, 2003 7:38 pm
by markl999
It's either not reaching that bit of code, or you need the space in ..
header("Location: http://seifer.travisbsd.org");
*note the space between the : http*

Posted: Thu Oct 16, 2003 7:39 pm
by Seifer
I could have sworn I had this error a year or so ago, and needed to put something at the top of the script.. I forget what though.

Posted: Thu Oct 16, 2003 7:43 pm
by Seifer
It is ob_start(); that I need to put at top, thanks for the input guys.

Posted: Thu Oct 16, 2003 7:43 pm
by markl999
Well, if there's an error somewhere above the header..then it will cause the header to fail as output has already been sent (the error). And if you're error_reporting isn't high enough and/or display_errors is Off then you won't see the error and the header will fail, hence a blank page ;)

So try

Code: Select all

<?php
error_reporting(E_ALL);
...
at the top.