Page 2 of 2
Posted: Thu Apr 15, 2004 7:07 pm
by John Cartwright
Code: Select all
<?php
<? session_start();
include('inc/connect.php');
if ($_SESSION['auth'] != 'authed')
{
$login='1';
include ('form.php');
}
if (isset($_POST['submit']))
{
$email = $_POST['email'];
$password = $_POST['password'];
$result = @mysql_query("SELECT * FROM user WHERE email='$email' && password='$password'") or die(mysql_error());
if(!mysql_num_rows($result))
{
die('Invalid username and/or password');
}else{
$row = mysql_fetch_array($result);
$userlevel = $row['userlevel'];
$_SESSION['auth'] = 'authed';
$_SESSION['userlvl'] = $userlevel;
if ($_SESSION['userlvl']=='admin')
{
header('Location: adminpanel.php');
exit();
}elseif ($_SESSION['userlvl']=='customer'){
header('Location: customerpanel.php');
exit();
}
}
}
?>
?>
Is outputting the header already sent msg... there is no output being outputted when there are no errors...
Posted: Thu Apr 15, 2004 7:14 pm
by markl999
What's the exact error message for the header? And what is the line that it says output was started on?
Posted: Thu Apr 15, 2004 7:18 pm
by John Cartwright
Warning: Cannot modify header information - headers already sent by (output started at /home/jcart/public_html/active/form.php:3) in /home/jcart/public_html/active/login.php on line 30
Posted: Thu Apr 15, 2004 7:22 pm
by markl999
So it's coming from include ('form.php'); which i presume includes the login form.
The code flow/logic should really be...
if not isset submit
then include the form and exit
else
if authenticated then redirect
else
show the login form (or reditect so it redisplays it)
Putting the form before the authentication will cause output, so it needs to only be shown if submit hasn't been pressed or authentication failed.
Hope that makes sense. If not let us knwo and i'll amend your code

Posted: Thu Apr 15, 2004 9:37 pm
by John Cartwright
thanks alot mark

Posted: Thu Apr 15, 2004 10:19 pm
by Illusionist
Phenom wrote:1 more problem... how do i send a header in the middle of a script without getitng the header already sent error... :S
I know your not new here...
and it is frowned upon when you ask questions that have been done a million times
viewtopic.php?t=1157
check that out...
Posted: Thu Apr 15, 2004 10:22 pm
by John Cartwright
I know that I couldn't have output... but i didn't see where the output was coming from giving me the error.... ty gg bye.
while ($illusionist != 'productive'){
slap illusionist with a trout
}