Jump to content

Setcookie Header Already Sent


gmz1023
 Share

Recommended Posts

Hey guys. I've googled the ###### out of this error and still can't get it to work. i get this error

Warning: Cannot modify header information - headers already sent by (output started at /home1/secregco/public_html/test/inc/functions.php:3) in /home1/secregco/public_html/test/login.php on line 24Warning: Cannot modify header information - headers already sent by (output started at test/inc/functions.php:3) in /test/login.php on line 25

whenever i try to log in to my site. it does send me to the correct page afterwords but the fact that i'm getting an error isn't good. (duh).this is the functions.php

<?php function redirect($parm,$title="") {?><meta http-equiv="refresh" content="2;url=<?php print($parm); ?>"><link href="assetts/misc.css" rel="stylesheet" type="text/css"><body bgcolor="#fff" text="#ffffff"><table id="please">  <tr>    <th>System Message</th>  </tr>  <tr>    <td> Please wait while we redirect you. </td>  </tr>  <?php }?></table>

this is the login.php

<?php require("inc/functions.php");if((!isset($_GET["user"])) && (!isset($_GET["pass"])) ){redirect("index.php"); exit;}$user=$_GET["user"];$pass=$_GET["pass"];$fp=fopen("inc/users.db","r");$userdata=array();$redirect="";while (($userdata = fgetcsv($fp, 1000, ",")) !== FALSE){if (($userdata[0]==$user) && ($userdata[1]==$pass)){ $redirect=$userdata[2]; }}fclose($fp);if ($redirect==""){redirect("index.php","Security Check : Fail");}else{setcookie("user",$user,time()+3600,"/"); setcookie("pass",$pass,time()+3600,"/");redirect($redirect,"index.php?hmb=wru");}exit;?><body><pre>User entered :<?php print ($user . "/" . $pass);  if ($redirect<>"") {print("OK -> ".$redirect); } else {print("KO -> index"); } for ($i=0;$i<count($userdata);$i++) {  print($userdata[0] . "|" . $userdata[1] . "|" . $userdata[2] . "\n" ); } ?></pre>

anyhelp would be appreciated.

Edited by gmz1023
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...