Page 1 of 1

[56K WARN] Problem in PHP Guestbook

Posted: Wed Mar 28, 2007 12:02 pm
by indianlibra
I created the guestbook's table in my database

all things looks perfectly ok, but i don't know where's the problem

this script is not completed

but its enough to insert the values in the table

i don't have any idea where i maked mistake

i wasted my 2 hour just for searching the its problem

can u find the it

Code: Select all

<?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);
	//only write to database if there's a 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>Gestbook</title>
</head>
<body>
<center>
<form action="<?php echo $_SERVER[PHP_SELF]; ?>" method="POST">
	<font face="arial" 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_comment"></textarea>
		<center><input type="submit" value="Submit"></center>
	</font>
</form>

</center>
</body>
</html>
Image 1
Image

Image 2
Image


Image 3
Image


Image 4
Image


Image 5

Image

Posted: Wed Mar 28, 2007 1:00 pm
by Begby
This

$_SERVER[PHP_SELF]

Should be this

$_SERVER['PHP_SELF']

Posted: Wed Mar 28, 2007 1:56 pm
by indianlibra
Begby wrote:This

$_SERVER[PHP_SELF]

Should be this

$_SERVER['PHP_SELF']
i worked

gosh i can't believe i make this silly mistake

but thanks Bedby