View Single Post
  #1 (permalink)  
Old August 12th, 2004, 05:12 AM
squared_ring squared_ring is offline
Registered User
 
Join Date: Aug 2004
Location: , , Singapore.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default PHP ( Cannot modify header information)

hello ppl.. well i was learing to use cookies, but i am stuck cus the below posted script generates

Warning: Cannot modify header information - headers already sent by (output started at D:\xtams\xtams-php\pm.php:1) in D:\xtams\xtams-php\pm.php on line 15
cannot set cookie

error occors at the red indicated lines..

I tried to check if this script is sending ne info or white space to the browser.. but doesnt seem to be.. i mean before setcookie() funcn.

pls help..
thanks

<?php
$dbhost = 'localhost';
$dbusername = '';
$dbpasswd = '';
$database_name = 'xpm_db';
$conn = mysql_pconnect("$dbhost","$dbusername","$dbpasswd" ) or die ("Couldn't connect to server.");
$db = mysql_select_db("$database_name", $conn) or die("Couldn't select database.");
$username=$_REQUEST["form_username"];
$password=$_REQUEST["form_password"];
$sql = "SELECT * FROM users WHERE user='" . $username. "' AND pass='".$password."'";
$result = mysql_query($sql,$conn) or die(mysql_error());
$RecTotal= mysql_num_rows($result);
if ($RecTotal != 0)
    {
setcookie("xpm_user", $row["user"], time()+60, "/", ".localhost.", 0) or die("cannot set cookie");
    }
    else
    {
            Header ("location: \"login.php\"");
    exit;
    }
?>

Reply With Quote