Jump to content
Sign in to follow this  
gmz1023

Setcookie Header Already Sent

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

Share this post


Link to post
Share on other sites

This warning is a nice example of using php in the wrong order. You have to MAKE the website and proces query's first using php. In the ideal situation your last php outputs the entire website in one line

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...