Page 1 of 1

redirection question

Posted: Fri Dec 10, 2004 9:55 pm
by havoc123
hello, i was wondering if anyone can help me out with why the header function isn't working. any help will be great appreciated.
thanks in advance,
havoc123

<html>
<head>
<title>Acuity: HR Manager Login</title>
<!-- use employer login as title -->
<link href="../assets/global.css" rel="stylesheet" type="text/css">
</head>
<body>
<?php include("../assets/nav/header.htm"); ?>
<?php include("../dbconnect.php"); //include dbconnect.php,so we can connect to database
?>
<div class="topRight">Welcome <?php echo $Username ?> | <a href="../index.html">Logout</a></div>
<h1> HR Manager Login</h1>

<div>
<form action="employer_login.php" method=post>
<h3>Already have an HR Manager Account? </h3>
Please login to post jobs and edit your profile.<br>
Enter your registered email and password.
<br>
<?php
print ("<table><tr><td>Username: </td>");
print ("<td> <input type=text name=Username value=\"$Username\" size=20></td></tr>");
// username textbox with initial value
?>
<tr><td>Password: </td><td> <input type=password name=Password size="20"></td></tr>
</table>
<br>
<input type=submit name=submit value="submit">
<input type=button value="back" onClick="history.go(-1)">
<br><a href="../help/index.htm">Log-in help</a>

</form>
<?php
if($submit)
{

if (trim($Username) == "") //check if the value is empty or not if it is then print the message
{
print ("You didn't enter the username.");

}

if (trim($Password) == "") //check if the value is empty or not if it is then print the message
{
print ("You didn't enter the password.");

}


$result = mysql_query("select * from employer where email=\"$Username\" and password=\"$Password\"");
// select data from database table name employer where username and password match to the values

if ($result) // if result is true find if the value is in the database
{
$row = mysql_fetch_array($result);
}

if ($row) // if it's true then you match the username and password and allow to login
{
$status = $row["status"];
if ($status == "active")
{
print ("You have successful logged in as $Username. ");
header('Location: http://members.lycos.co.uk/hgalura/mile ... _index.php');
//redirect("../employer/employer_index.php?Username=$Username");
//print ("<h2><a href=\"../employer/employer_index.php?Username=$Username\">HR Manager Center</a></h2>");
// print a message and a hyperlink with passing value username. The link goes to main page
}
else
{
print ("You can not access the account $Username. ");
print ("It is inactive.");
}
}
else
{
print ("You didn't enter the correct username or password or both.");
// if not true, showing the error message
}
mysql_free_result($result);// disconnect with database
}
?>
</div> <!--end of left half-->

<div>

<h3>New to Acuity?</h3>
Get a free <a href="new_employer.php">Acuity HR Manager</a> account -- it is a breeze to post jobs and search resumes.
</div>


<?php include("../assets/nav/footer.htm"); ?>

</body>
</html>

Posted: Fri Dec 10, 2004 9:59 pm
by rehfeld
you cant send a header after you have sent output. output is any html, text, spaces, new lines etc....

you may want to take a look at ob_start()

Posted: Fri Dec 10, 2004 10:22 pm
by Benjamin
Welcome to the Devnetwork forums. Please be sure to read viewtopic.php?t=21171