<?php
mysql_connect("localhost","xxxxx","xxxxx") or die(mysql_error());
mysql_select_db("xxxxx_comments")or die(mysql_error());
if (isset($_POST['submit'])) {
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
$date=strftime("%a %b %d %Y %H:%M:%S");
$url= curPageURL();
$sql="INSERT INTO comments (username, date, comment, url)
VALUES ($username,$date,'".$_POST['comment']."',$url)";
mysql_query($sql);
?>
Comment Submitted
<?php
}
else
{
?>
<table width="286" height="185" align="right">
<tr>
<td width="79" height="179"><div align="left">
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<p>
<textarea name="comment" cols="69" rows="7" wrap="VIRTUAL" id="comment"></textarea>
<input type="submit" name="submit" value="Comment">
</p>
</form>
</div></td>
</tr>
</table>
<?php
}
?>
There are no errors, it will display the "Comment Submitted", but no records are created in the database.