User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 391,944 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,882 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1172 | Replies: 1
Reply
Join Date: May 2005
Posts: 26
Reputation: Yuki H. is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
Yuki H.'s Avatar
Yuki H. Yuki H. is offline Offline
Light Poster

header information error

  #1  
Jul 21st, 2005
I have this header information error while I was playing with a script.

Warning: Cannot modify header information - headers already sent by (output started at /home/user/public_html/layouts/connection.php:8) in /home/user/public_html/layouts/addcomments.php on line 23

I wanted the page to redirect itself after submitting the comment, but I messed up.
I also want to know how do I make the url text area capible of accepting urls and emails.
addcomments.php
[PHP]<?php
include('connection.php');
$action = strip_tags($_GET["action"]);
$id = strip_tags($_GET["id"]);

if ($action=="add")
{
$name = strip_tags($_POST["name"]);
$entry = strip_tags($_POST["entry"]);
$email = strip_tags($_POST["email"]);

// add comments
if (empty($name) || empty($entry))
{
die ("Error, you cannot submit a blank entry.");
}

$q = "insert into layout_comments (id, name, email, date, layout_id, entry) VALUES

('','$name','$email',now(),'$id','$entry')";
$result= mysql_query($q) or die
("Could not execute query : $q." . mysql_error());
if ($result)
{
header('Location: addcomments.php');

}

}
else {


?><form action="<?php echo "addcomments.php?action=add&id='$id' "; ?>" method="post">
<table width="130" border="0" cellspacing="1" cellpadding="0">
<tr>
<td height="23" colspan="2"><b>Add Comments</b></td>
</tr>
<tr>
<td>Name</td>
<td>
<input type="text" name="name" size="30">
</td>
</tr>
<tr>
<td height="25">Url:</td>
<td height="25">
<input type="text" name="email" size="30">
</td>
</tr>
<tr>
<td height="25">Comments</td>
<td height="25">
<textarea name="entry" cols="30" rows="5"></textarea>
</td>
</tr>
<tr><td colspan=2><input type="submit" value="submit"></td></tr>
</table></form>
<?php
}
?>
<?
$id = strip_tags($_GET["id"]);

$q = "SELECT * from layout_comments where layout_id='$id' order by date desc ";
$result= mysql_query($q) or die
("Could not execute query : $q." . mysql_error());


while ($row=mysql_fetch_array($result))
{
$id=$row["id"];
$name=$row["name"];
$email=$row["email"];
$entry=$row["entry"];
$date=$row["date"];
$layout_id = $row["layout_id"];

?>

<table width="80%" border="0" cellspacing="1" cellpadding="0" align="center">
<tr>
<td>Comments for <?php echo "$title"; ?></td>
</tr>
<tr>
<td>
<?php echo "$entry"; ?>
<p>Posted by <a href="<?php echo "$email"; ?>"><?php echo "$name"; ?></a> on <?php

echo "$date"; ?>.</p>
</td>
</tr>
</table>

<?php
}


?>[/PHP]
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2005
Location: Kansas City, Missouri, USA
Posts: 344
Reputation: Troy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 4
Troy's Avatar
Troy Troy is offline Offline
Posting Whiz

Re: header information error

  #2  
Jul 21st, 2005
In a quick glance at your code, it does not appear that your are outputting anything before you attempt the header() function. So, my guess is either:

1. connection.php is outputting something using echo(), print(), etc.
2. You have whitespace before or after the initial and final <?PHP ?> tags in the connection.php include file.

I do not understand what you are asking here:
...how do I make the url text area capible of accepting urls and emails.
It will accept a URL or email address---anything your user can type on the keyboard can be typed into that text input.
Troy Wolf is the author of SnippetEdit. "Website editing as easy as it gets." IX Web Hosting
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 8:55 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC