A
Anonymous
Guest
Hi I was writing some code for a guestbook but somehow the data is not being entered in the database ie the guestbook table is empty. The code im using is below. Any ideas why it wont work? tnx
<?php
require($_SERVER["DOCUMENT_ROOT"]."/config/db_config.php");
$connection = @mysql_connect($db_host, $db_user, $db_password) or die("error connecting");
mysql_select_db($db_name, $connection);
$name=$_post["txt_name"];
$len=strlen($name);
if ($len>0)
{
$email = $_post["txt_email"];
$comment = $_post["txt_comment"];
$date = time();
$query = "insert into guestbook(autoID, name, email, comment, date_auto) VALUES(NULL, '$NAME', '$EMAIL','$COMMENT','$DATE')";
MYSQL_QUERY($query, $connection) or die(mysql_error());
}
?>
<html>
<head>
<title>Guestbook</title>
</head>
<body>
<center>
<form action="<?php echo $_SERVER[php_self]; ?>" method="get">
<font face="verdana" size="1">
Name: <input type="text" name="txt_name">
Email: <input type="text" name="txt_email"><br><br>
Comment:<br>
<textarea style="width: 75%" rows=10 name="txt_comments"></textarea>
<p>
<center><input type="Submit" value="Submit"></center></p>
</font>
</form>
</center>
</body>
</html>
<?php
require($_SERVER["DOCUMENT_ROOT"]."/config/db_config.php");
$connection = @mysql_connect($db_host, $db_user, $db_password) or die("error connecting");
mysql_select_db($db_name, $connection);
$name=$_post["txt_name"];
$len=strlen($name);
if ($len>0)
{
$email = $_post["txt_email"];
$comment = $_post["txt_comment"];
$date = time();
$query = "insert into guestbook(autoID, name, email, comment, date_auto) VALUES(NULL, '$NAME', '$EMAIL','$COMMENT','$DATE')";
MYSQL_QUERY($query, $connection) or die(mysql_error());
}
?>
<html>
<head>
<title>Guestbook</title>
</head>
<body>
<center>
<form action="<?php echo $_SERVER[php_self]; ?>" method="get">
<font face="verdana" size="1">
Name: <input type="text" name="txt_name">
Email: <input type="text" name="txt_email"><br><br>
Comment:<br>
<textarea style="width: 75%" rows=10 name="txt_comments"></textarea>
<p>
<center><input type="Submit" value="Submit"></center></p>
</font>
</form>
</center>
</body>
</html>