hey guys,
i recently started to learn some web design and thanks to all these forums, i have learned alot. but i ended up being too greedy and tried to put a comment box in my site, which put me into a lot of trouble.
i have now managed to create the form in HTML for my visitors to input their info and created a database in MySQL and connected to it using a PHP file. i can now post data to the dataase but when clicking submission button it shows me an error page saying: Warning: Cannot modify header information - headers already sent by (output started at /home/content/a/d/l/myusername/html/Library/guestbook.php:1) in /home/content/a/d/l/myusername/html/Library/guestbook.php on line 42
i dont know what i'm doing wrong here. this is the guestbook.php am using, which is in a directory called Library:
and here is the HTML code for the form i use:PHP Code:<?php
include 'config.php';
include 'opendb.php';
if(isset($_POST['btnSign']))
{
include 'config.php';
include 'opendb.php';
$name = trim($_POST['txtName']);
$email = trim($_POST['txtEmail']);
$url = trim($_POST['txtUrl']);
$message = trim($_POST['mtxMessage']);
if(!get_magic_quotes_gpc())
{
$message = addslashes($message);
}
// if the visitor do not enter the url
// set $url to an empty string
if ($url == 'http://')
{
$url = '';
}
$query = "INSERT INTO guestbook (name,
email,
url,
message,
entry_date)
VALUES ('$name',
'$email',
'$url',
'$message',
current_date)";
mysql_query($query) or die('Error, query failed');
header('Location: ' . $_SERVER['REQUEST_URI']);
exit;
}
?>
thank you all very much for all the effortHTML Code:<form method="post" name="guestform" action="Library/guestbook.php"> <table width="550" border="0" cellpadding="2" cellspacing="1"> <tr> <td width="100">Name *</td> <td><input name="txtName" type="text" id="txtName" size="30" maxlength="30"></td> </tr> <tr> <td width="100">Email</td> <td><input name="txtEmail" type="text" id="txtEmail" size="30" maxlength="50"></td> </tr> <tr> <td width="100">Website URL</td> <td><input name="txtUrl" type="text" id="txtUrl" value="http://" size="30" maxlength="50"></td> </tr> <tr> <td width="100">Message *</td> <td><textarea name="mtxMessage" cols="80" rows="5" id="mtxMessage"></textarea></td> </tr> <tr> <td width="100"> </td> <td><input name="btnSign" type="submit" id="btnSign" value="Sign Guestbook" onClick="return checkForm();"></td> </tr> </table> </form>
Adler,



Reply With Quote
but the good fact is that i learn as fast as a skyrocket 

Bookmarks