No white space at top. Authentication function is in the same script. Here
is the rest of it. PHP 4.1.1, Apache 1.3.23.
function authenticate($user, $pass)
{
// move this to the config.php file
$db_host = "localhost";
$db_user = "user";
$db_pass = "password";
$db_name = "database";
//check login and password
//connect and execute query
$connection = mysql_connect($db_host, $db_user, $db_pass) or die ("Unable
to connect!");
$query = "SELECT ID from users WHERE login = '$user' AND pass =
PASSWORD('$pass')";
mysql_select_db($db_name);
$result = mysql_query($query, $connection) or die ("Error in query: $query
. " . mysql_error());
// if row exists -> user/pass combination is correct
if (mysql_num_rows($result) == 1)
{
return 1;
}
// user/pass combination is wrong
else
{
return 0;
}
}
// close database connection
mysql_close($connection);
?>
-----Original Message-----
From: Mike Flynn [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 01, 2002 11:08 AM
To: [EMAIL PROTECTED]; PHP Win32 (E-mail)
Subject: Re: [PHP-WIN] Premature end of script headers: c:/php/php.exe
1. Is there any whitespace before the first <? tag?
2. Where is the authenticate function defined -- what does it do, what's
its code, etc? Could it be returning HTML prematurely?
Otherwise everything looks ok.
-Mike
At 11:03 AM 5/1/2002 -0400, Dean Sadler wrote:
>I am having troubles with the following script. When executed I get the
500
>internal server error page and an error: Premature end of script headers:
>c:/php/php.exe in the log files. If I comment out the header() line it
>works fine. I would like to redirect to the proper page based on login
>pass/fail. Can any one see what I am doing wrong?
>
><?
>// Login script
>//authenticate using form variables
>$status = authenticate($f_user, $f_pass);
>
>// if user/pass is correct
>if ($status == 1)
>{
> //initiate a session
> session_start();
>
> //register some session variables
> session_register("SESSION");
>
> //including the username
> session_register("SESSION_UNAME");
> $SESSION_UNAME = $f_user;
>
> //redirect to page
> header("Location: /worked.php"); //<-- problem area.
> exit();
>}
>else
>// user/pass failed
>{
> //redirect to error page
> header("Location: /failed.php");
> exit();
>}
>
>---snip---
>
>
>--
>PHP Windows Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
Mike Flynn - Burlington, VT
http://www.mikeflynn.net/ - [EMAIL PROTECTED]
home=>work=>home=>store=>home [repeat daily]
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php