arjanh is right. all the headers, cookies, session cookies and all that stuff must be sent BEFORE a single line of a text is echoed, oherwise they won't be sent.
Main Topics
Browse All TopicsHi there, I am trying to re-direct users to a thank you page. But I get a header error because the code thinks that I have already sent a header as part of session variables and as such, cannot create another. Can someone help me with this problem?
--------------------------
err
====
Warning: Cannot add header information - headers already sent by (output started at /home/4435/pebbles/www.six
code
===
<?php
session_name();
session_start("first_name"
session_start("last_name")
session_start("cust_num");
session_start("username");
session_start("email");
if ((!(session_is_registered(
(!(session_is_registered("
(!(session_is_registered("
(!(session_is_registered("
(!(session_is_registered("
{
session_unset();
session_destroy();
$url = "Location: re_userlogin.php";
header($url); -------- header 1
}
else
{
echo "<b>Hello $first_name $last_name, you are Customer No. $cust_num, you are logged
in.</b>";
}
?>
<?php
//brians code start here
include "functions.inc.php";
include "error_messages.inc.php";
//action=add means usr pressd the submit button
if ($action =="add")
{
$error_found=false;
$error="";
//start validating the user input
}
if($co_name=="")
{
$error_found=true;
$error.=ERR_CO_NAME_BLANK;
}
if($inda=="")
{
$error_found=true;
$error.=ERR_INDUSTRY_BLANK
}
if($position=="")
{
$error_found=true;
$error.=ERR_POSITION_BLANK
}
if($equip=="")
{
$error_found=true;
$error.=ERR_EQUIP_BLANK;
}
if(!$error_found)
{
$db_name = "afa";
$table_name = "_089";
$connection = @mysql_connect("mysql", "ps", "nro") or die("Couldn't connect.");
$db = @mysql_select_db($db_name,
$sql = "insert into $table_name(
email,
co_name,
inda,
other,
url,
position,
hours,
cost,
equip,
web_source,
username,
cust_num,
agent,
status,
date_reg,
type)
values(
\"$email\",
\"$co_name\",
\"$inda\",
\"$other\",
\"$url\",
\"$position\",
\"Open all year Round\",
\"Available on Request\",
\"$equip\",
\"bizafrican\",
\"$username\",
\"$cust_num\",
129,
\"active\",
curdate(),
\"client\")";
$result = mysql_query($sql,$connecti
$sql1 = "update _089 set inda = \"089\" where inda = \"_089\" ";
$result1 = mysql_query($sql1,$connect
Header("Location: do_089xx.php"); -------- header 2 -- not working
exit;
}
else
{
$error=ERR_HEADER.$error;
}
?>
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
If you want to display content, then you should use a META refresh redirect or a JavaScript SetTimeout() redirect. Either one will work, and you can just replace Header("Location: do_089xx.php"); with <meta http-equiv="refresh" content="2; url='do_089xx.php'"> or <script> setTimeout((window.locatio
If you don't want to display any content on this page, place the function ob_start(); at the top of your page. This will enable output buffering and you can send all the content out to the screen that you want and still utilize headers.
- Matt
Business Accounts
Answer for Membership
by: arjanhPosted on 2003-11-30 at 06:50:55ID: 9845255
You cannot do the
echo "<b>Hello $first_name $last_name, you are Customer No. $cust_num, you are logged in.</b>";
and then later on set a Location: header. Try removing that echo bit.