Jump to content

Recommended Posts

 <?php
mysql_connect("localhost","root") or die(mysql_error());
mysql_select_db("forum")or die(mysql_error());

  $switch=strip_tags($_GET['do']);

  switch($switch){
  
  case 'newtopic':
  
  if(isset($_POST['Submit'])){
  if(empty($_POST['title'])||empty($_POST['message'])){
  
   die("Refreshing...<META HTTP-EQUIV='refresh' content='0;URL=http://localhost/forum_software/?page=newtopic&forum=".$_GET['forum']."&notice=100'>");
  
  }
    if(ucfirst($_POST['title'])=="Topic Title"){
  
   die("Refreshing...<META HTTP-EQUIV='refresh' content='0;URL=http://localhost/forum_software/?page=newtopic&forum=".$_GET['forum']."&notice=100'>");
  
  }
    if(ucfirst($_POST['message'])=="Message"){
  
   die("Refreshing...<META HTTP-EQUIV='refresh' content='0;URL=http://localhost/forum_software/?page=newtopic&forum=".$_GET['forum']."&notice=100'>");
  
  }
  elseif(strlen($_POST['message']) > 20000){
  
     die("Refreshing...<META HTTP-EQUIV='refresh' content='0;URL=http://localhost/forum_software/?page=newtopic&forum=".$_GET['forum']."&notice=200'>");
  
  }
    elseif(strlen($_POST['title']) > 35){
  
     die("Refreshing...<META HTTP-EQUIV='refresh' content='0;URL=http://localhost/forum_software/?page=newtopic&forum=".$_GET['forum']."&notice=300'>");
  
  }
  else
  {
  
  $title=htmlentities($_POST['title']);
  $message=htmlentities($_POST['message']);
  
  $title=mysql_real_escape_string($title);
  $message=mysql_real_escape_string($message);
  $id=strip_tags($_GET['forum']);
  $id=mysql_real_escape_string($id);
  
  $date=date('Y-m-d H:i:s'); 

      $query=mysql_query("insert into topics (id_forum,title,message,reply_date) VALUES ('$id','$title','$message','$date')") or die (mysql_error());
  $result=mysql_query("SELECT * FROM topics ORDER BY reply_date DESC LIMIT 1");
  $data=mysql_fetch_assoc($result);
  $date2=$data['reply_date'];
  $update=mysql_query("update forum_title SET last_topic = '$date2' WHERE id = '$id'");
   $update=mysql_query("update forum_title SET total_topic = total_topic + 1 WHERE id = '$id'");
  $ip=$_SERVER['REMOTE_ADDR'];
setcookie("flood",$ip,time()+30);	     

die("Refreshing...<META HTTP-EQUIV='refresh' content='0;URL=http://localhost/forum_software/?page=newtopic&forum=".$_GET['forum']."&notice=500'>");
  
  
  }
	  }
  break;

}
?>

 

I cant set a cookie because the header has already been sent? I dont get it, and the code is outside the head tags, on top of my page.

 

Help?

Link to comment
https://forums.phpfreaks.com/topic/66548-header-already-sent/
Share on other sites

Unless im being completely blind, you've not included the part of the code that sets the cookie. Therefore, we can't suggest where the output is coming from.

 

Also, the error message will tell you what line the header was already sent by. It would be useful to have that information. Help us help you.

Link to comment
https://forums.phpfreaks.com/topic/66548-header-already-sent/#findComment-333314
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.