Need help with a PHP Comment box?

mags_best

New member
i have a little comment box rig set up where i have an html form processed by php and stored into a database. Now the point of this is, on my personal website i want the comments submitted to the database on the day anyone happens to be visiting the site to be displayed on a section of my website. i tried to use this php script to have that happen.
<?php
$server = "xxxxxxxxx";
$password = "*********";
$database = "xxxxxx";
$user_name = "xxxxxxx";
$table_name = "Comments";
$db_handle = mysql_connect($server, $user_name, $password);
$db_found = mysql_select_db($database, $db_handle);
$date = date("m/d/y");
$result = mysql_query("SELECT TOP 5 Names, Comment FROM Comments WHERE Timestamp="$date"");
if(!$result)
echo("Sorry No Comments T_T");
else
echo($result);

?>

The problem is i have tried multiple things to have it happen and i realised that any sql code i put into my scripts wont display properly codes that i know work because theyre provided on tutorial sites. I've been working for hours to fix this and i cant figure out how. the data from the form is stored in the database flawlessly but for some reason i cant get php to display the output from the database on my page. if it helps here is the php script that inputs the data in to the database
<?php
$server = "***************";
$password = "*******";
$database = "********";
$user_name = "*********";
$db_handle = mysql_connect($server, $user_name, $password);
$db_found = mysql_select_db($database, $db_handle);
mysql_query("INSERT INTO Comments (Name, Email, Comment, Timestamp)
VALUES ('$_POST[firstname]','$_POST','$_POST[comment]', '$_POST[time]')");
?>
here is the form
<form name="input" action="index.php" method="post">
<p class="style1"><br/>
<input type="hidden" name="time" value="<?php $b = time (); print date("m/d/y",$b);?>" />
Firstname<br/>
<input type="text" name="firstname" />
<br/>
Email <span class="caption">*For Contact Purposes Only Not To Be Displayed*</span><br />
<input type="text" name="email" />
<br />
Your Comment<span class="caption">*Dont worry if you dont see yours we got it :]*</span><br />
<textarea name="comment">
</textarea>
<br/>
<input type='submit' value='Submit' onclick='this.value = "Posted!"; this.disabled = true'/>
</p>
</form>

also if it helps im using godaddy.com hosting Please anyone help i need to get this done.
 
Back
Top