hello everybody
i am getting this type of error(shown below) after submitting the button in IE
browser, but the same code is working on Firefox smoothly,
Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\pho enixhrsolutions \login.php:8) in C:\wamp\www\pho enixhrsolutions \login.php on line 126
i have database driven login authentication scripts. from the login page, if i enters username and password i am getting errors as shown above
any body knows please send me the solution
thank you
4 1100 Atli 5,058
Recognized Expert Expert
Hi.
The Warning you are getting there is produced by you PHP server-side code, so it is very unlikely that it would have anything to do with which browser you are using...
In any case. This warning is produced when you try to use the header() function after something has been printed. Once any content has been added to the response, the header information is locked an you can not modify it.
For example, this here will produce this warning, and you won't be redirected: -
<?php
-
echo "Hello";
-
header("Location: http://www.google.com");
-
?>
-
While this will send you to Google. -
<?php
-
header("Location: http://www.google.com");
-
echo "Hello";
-
?>
-
Check out the Output Control Functions for a simple way to control your output.
Thanks a lot for ur reply, i am struggling very much from this issue,
but still i have doubt, and i.e not cleared, below i sending my script please
have a look, I will explain the script logic how the control is going.
once user enters username and password, then that values will compare with the database tables, if username is valid then it will create one session variable,
once session variable is set then that page is redirecting to index.php
index.php contains and header.php and footer.php
so, my question is where i have to put header information(i.e . redirection page). -
<?php
-
session_start();
-
-
include_once("functions.php");
-
$cxn = connect_to_db("vars.php");
-
?>
-
<html>
-
<head>
-
<script language='javascript'>
-
function load() {
-
var formObj = document.loginFrm.username;
-
formObj.focus();
-
}
-
</script>
-
<title>Phoenix HR Solutions Login page</title>
-
<link rel="stylesheet" href="style.css">
-
</head>
-
<body background=back.gif onload='load();'>
-
<?php
-
#echo date("d/m/Y");
-
function confirmUser($username,$password)
-
{
-
-
#$query = "Select username, password from Users where username='$username' and password='$password'";
-
-
$query = "Select Name, Confm_Passwd from Recruiter_Profile where Name='$username' and Confm_Passwd ='$password'";
-
-
-
#echo $query;
-
-
$result = mysql_query($query) or die("Cannot execute the query");
-
#echo $result;
-
$row = mysql_num_rows($result);
-
-
#echo $row;
-
if(mysql_num_rows($result) != 1)
-
-
return false; // 1 username exists
-
-
else
-
-
return true;
-
-
}
-
?>
-
<table bgcolor="#EDEDED" align="center" width=800 height=600 border=0 >
-
<tr width=100% height=5% cellpadding=0><td colspan=8 background="sidebar.gif" width=10% height=5% class="ttitle"><div id="tttitle1"><img src="logo1.gif" ></img></div><div> PHOENIX HR SOLUTIONS </div> </td>
-
</tr>
-
-
<tr><td>
-
<table border='0' height=20% cellspacing="8" cellpadding="8" align=center background=sidebar.gif class="MenuTable">
-
<form method='post' name='loginFrm' action='login.php'>
-
<br><br><br><br></br>
-
<tr><td colspan=2 align=center class='field' style="font-family:verdana; font-size:12pt;">LOGIN</td></tr>
-
<tr>
-
<td class="Elementname"><b>User name</b></td><td><input type='text' size='20' name='username'></td></tr>
-
<tr>
-
<td class="Elementname"><b>Password</b></td><td><input type='password' size='21' name='pass'></td><br />
-
-
<tr class=element><td colspan="2" align="center"> <input type='submit' name='submit' value=' login '> </td>
-
</tr>
-
</form>
-
</td>
-
</tr>
-
<?php
-
$username = $_POST['username'];
-
$password = $_POST['pass'];
-
$submit = $_POST['submit'];
-
-
#echo ($username);
-
$crypt_pwd=md5($password);
-
#echo ($crypt_pwd);
-
-
if(!empty($submit)){
-
-
if (!empty($username) && !empty($password)) {
-
-
#$cxn = mysql_connect("localhost","root","mysql");
-
-
#$db = mysql_select_db("phoenixhrdb",$cxn);
-
-
$auth = confirmUser($username,$crypt_pwd);
-
-
#echo "\n$auth";
-
-
if ($auth == "true") {
-
-
$_SESSION['valid_user'] = $username;
-
# Write query ( select MAX(login_time) from logintimestamp where username='$username';
-
#write the result into $lastlogin
-
# insert into logintimestamp values ($username, now(), NULL);
-
# :wq
-
-
$time_query = "select MAX(logintime) from Logintimestamp where Username='$username'";
-
#echo $time_query;
-
$time_result = mysql_query($time_query,$cxn);
-
$time_row = mysql_fetch_array($time_result);
-
$lastlogin = $time_row['MAX(logintime)'];
-
#echo $lastlogin;
-
$_SESSION['login'] = $lastlogin;
-
-
$insert_query = "INSERT INTO Logintimestamp values ('$username',now(),'NULL')";
-
# echo $insert_query;
-
$insert_result = mysql_query($insert_query,$cxn);
-
-
# }
-
if(true){
-
$adminquery ="select Name from Recruiter_Profile where Team_Selection='Superuser' or Team_Selection='Management' or Team_selection='Manager'";
-
$adminresult = mysql_query($adminquery) or die("Could not connect to database".mysql_error($cxn));
-
#echo $adminresult;
-
-
while($adminrow = mysql_fetch_array($adminresult)){
-
#echo $adminrow;
-
$adminteam[]=$adminrow['Name'];
-
}
-
foreach($adminteam as $admin){
-
# echo "<br>$admin";
-
#echo $username;
-
if($admin==$username){
-
# echo $admin;
-
header("Location:index.php");
-
exit;
-
}
-
else if($admin !=$username){
-
header("Location:indexcontinue.php");
-
exit;
-
}
-
}}
-
}
-
else {
-
-
echo ("<tr><td colspan='2'><b align='center'>Username or Password doesn't exist</b></td></tr>");
-
}
-
-
}
-
-
-
else {
-
-
-
echo ("<tr><td colspan='2'><b>Please Enter user name and Password</b></td></tr>");
-
}
-
-
}
-
?>
-
</table>
-
</td></tr>
-
<tr height=15><td align=center background="sidebar.gif" colspan=8 cellpadding=0 cellspacing=0 class=footertxt>copyright2007 @ phoenixhrsolutions</td></tr>
-
</table>
-
</body>
-
</html>
-
Atli 5,058
Recognized Expert Expert
The header() function must be called before anything is added to response. So calling the function where you do will never work. Unless you use the Output Control Functions.
A simpler example, in this case, would be to use Javascript to redirect the browser.
There is of course always a risk using Javascript, as the client's browser can be set to ignore Javascript.
You could try something like this, instead of your header call: -
echo "<script type=\"text/javascript\">location.href='http://www.google.com';</script>";
-
I would recommend, however, that you try to design all code, that requires the use of the header function, so that any calls the function are done before you print anything.
Thank you very much Mr.Atli
my problem has solved, in any php script logic should come first then the display part has to come
means in my script i am printing forms before callling header function i interchange as u said.
thank you
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: baustin75 |
last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie
only when debugging in php designer 2005
--------------------------------------------------------------------------------
Hello,
I have a very simple problem but cannot seem to figure it out. I have a
very simple php script that sends a test email to myself. When I debug
it in PHP designer, it works with no problems, I get the test email. If
|
by: Greg Scharlemann |
last post by:
Does the redirect statement:
header(Location:"http://www.newpage.com");
need to come before certain statements?
I've setup a login page and try to redirect a user once they have
logged in (after I set the appropriate $_SESSION value) but I get the
following error:
Warning: Cannot modify header information - headers already sent by
(...)
|
by: Chris Robb |
last post by:
I'm having some really odd behavior with a PHP script. I have it
populating an HTML select form with a for loop. When I try the years
2006 to 1900. I get the following error:
PHP Warning: Cannot modify header information - headers already sent
by (output started at
/Users/chrobb/Sites/city-directory/controlBar.php:54) in
/Users/chrobb/Sites/city-directory/controlBar.php on line 88
I've done a fair amount of searching and it looks...
|
by: J Huntley Palmer |
last post by:
I am getting this error:
Cannot modify header information - headers already sent by
when I issue a
header ("Location: http://www.foobar.com");
How can I redirect the user to such a site without encountering this error.
If I run the same code on two sites I will get the error on one site but
not the other.
|
by: lawrence k |
last post by:
How can I find out where my script is outputting to the screen for the
first time?
My error logs are full of stuff like this:
PHP Warning: session_start(): Cannot send
session cache limiter - headers already sent in
/home/httpd/vhosts/monkeyclaus.org/httpdocs/media/audio/pdsIncludes/CommandStartSession.php
on line 14
| |
by: mcserret |
last post by:
I know this is a recurring problem that has been addressed here
before, but even after reading all that has gone before, I am still
stumped.
I have a form that is designed to send data to a PHP page where is is
to be validated then read into a MySQL table. Once that is done, the
form is to send the user either back to the originating page, or to a
logout page.
I have several versions of this setup on my site that work well, so
|
by: pks83 |
last post by:
Hello
I am also facing this problem when i amtrying to send additional header information.
Warning: Cannot modify header information - headers already sent by (output started at header.php:96) in my.class.php on line 1198
What is happening over here is that i when i am trying to download an attached file i am passing the additional header information which is conflicting with the header info which has already being sent before.
...
|
by: jessica87 |
last post by:
hi there, i m using this coding to retrieve the file from database so that my user can download the file...
<?php
if (!isset($_GET)) die('Invalid Parameter');
include 'connectdb.php';
$id = $_GET;
|
by: JRough |
last post by:
I have the following code at the end of a page that lists some query
results. It starts in a form that asks the user for input, one of two
template pages. One template is a form for user input if there is
input otherwise it changes the template and lists the results on the
other template page. That is why there is a $template variable.
====
$template = "template_carlist.html";
if ($_POST!='Open in Excel'){
|
by: pinko1204 |
last post by:
My Update function cannot successful update to sql table even don't have any error. Please help to check .....thx
PHP1
<?php
require_once 'header.php';
?>
<style type="text/css">
<!--
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |