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 
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 
} 


?>

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.