473,387 Members | 1,553 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

postpone the sending of header information

tolkienarda
316 100+
hi all.

i am getting an error:
[PHP]
Warning: session_register() [function.session-register]: Cannot send session cookie - headers already sent by (output started at C:\wamp\www\WTA\admin\login.php:14) in C:\wamp\www\WTA\admin\login.php on line 20
[PHP]

and two other similar header errors. so i think i need to somehow stop the sending of headers untill the end of my script if anyone can impart their wisdom on the matter i would be greatful

eric
Mar 22 '07 #1
4 1619
iam_clint
1,208 Expert 1GB
you always want to set header information at the top of your code
Mar 22 '07 #2
tolkienarda
316 100+
ok

maybe my code isn't formated right. here is the code

[PHP]
<?
$host="localhost"; // Host name.
$db_user="eric"; // MySQL username.
$db_password="dal4120"; // MySQL password.
$database="wytrkcms"; // Database name.
$cms = mysql_pconnect($host, $db_user, $db_password) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database, $cms);
if(isset($_POST[uname]))
$user=$_POST[uname];
if(isset($_POST[pass]))
$pass=$_POST[pass];
session_start();
//session_destroy();
echo '1';
$result=mysql_query("SELECT user, pass FROM users WHERE pass = '$pass' AND user='$user'");
$row=mysql_fetch_row($result);
echo '2';
if($row[0] == $user && $row[1] == $pass)
{
session_register("user");
header("location:index.php");
}
else
{
header("location:login.htm");
}

?>
[/PHP]

me error says the problem is occuring on session_register("user"); line and the one below it. or if the password is incoret then on the other redirect tag.
do you know what i am doing wrong
Mar 22 '07 #3
ak1dnar
1,584 Expert 1GB
remove those echo '0' and echo '1' lines, i don't know what is reason for those stuffs.since you are using them in this first the page try to print them, then you can't use the session_start().
and wrap the post element with single quotes.

[PHP]if(isset($_GET['uname']))
$user=$_GET['uname'];
if(isset($_GET['pass']))
$pass=$_GET['pass'];[/PHP]

I change your script against to one of my table and it works.and redirected to index.htm with the values like this:
http://localhost/thescripts/621150/session.php?uname=1016&pass=123
Note that i used $_GET so do the changes. :)

[PHP]<?
$host="localhost"; // Host name.
$db_user="root"; // MySQL username.
$db_password="dba"; // MySQL password.
$database="test"; // Database name.
$cms = mysql_pconnect($host, $db_user, $db_password) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database, $cms);
if(isset($_GET['uname']))
$user=$_GET['uname'];
if(isset($_GET['pass']))
$pass=$_GET['pass'];
session_start();
//session_destroy();
//echo '1';
$result=mysql_query("SELECT p_id, p_name FROM products WHERE p_id = '$user' AND p_name='$pass'");
$row=mysql_fetch_row($result);
//echo '2';
if($row[0] == $user && $row[1] == $pass)
{
session_register("user");
header("location:index.php");
}
else
{
header("location:login.htm");
}

?> [/PHP]
Mar 23 '07 #4
tolkienarda
316 100+
thanks
i'll try those suggestions

eric
Mar 23 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: elbertlev | last post by:
Hi! I'm trying to use py-xmlrpc. All works fine (and very fast) in one-threaded case, but I really have to serve many clients. As advertised, py-xmlrpc supports non-blocking calls (via select)....
4
by: TomHL | last post by:
Hello, I want to send an additional info with byte array wiith sockets as "one packet". I know how to send the byte array by himself, but how can I send the additional info with it at the same...
4
by: splicemix | last post by:
Hi all, I have recently set up a Drupal website. I am a beginner. My shared host server does not allow nobody@localhost to send emails, and prevents access to php.ini, so I spent some time...
6
by: Anuradha | last post by:
Dear All How can i send mails using vb.net Thanx all
3
by: Sells, Fred | last post by:
I'm using MSW XP Pro with Python 2.4 to develop but production will be Linux with Python 2.3. (could upgrade to 2.4 if absolutely necessary) I can also switch to Linux for development if...
1
by: robbiesmith79 | last post by:
Just so this is out there on the web, I battled the past 24 hours about this. Background info... I developed a ecommerce website in PHP 4 on a shared linux hosting plan from GoDaddy and had the...
3
crystal2005
by: crystal2005 | last post by:
I found such eror message when i tried to test sending email. Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in...
7
by: undbund | last post by:
Hi I am creating a newsletter system. The software should run from desktop computer (localhost) but be able to send email to anyone on the internet. Can you guys give me some ideas on how to...
8
by: nargis2009 | last post by:
Hi, I have been encountering problems with my web page which is supposed to send email, and wondered if anybody can help find error. Initially I had all codes in one page and on click of...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
Oralloy
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.