I included this somewhere on the website:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Comment system using php and mysql</title>
</head>
<body>
<?php
mysql_connect("localhost", "root", "")or die("cannot connect server ");
mysql_select_db("comments")or die("cannot select DB");
?>
<form name="comment" method="post" action="comment.php" onSubmit="return validation()">
<table width="500" border="0" cellspacing="3" cellpadding="3" style="margin:auto;">
<tr>
<td align="right" id="one">Name :<span style="color:#F00;">*</span></td>
<td><input type="text" name="namename" id="tnameid"></td>
</tr>
<tr>
<td align="right" id="one"></td>
<td><textarea name="message" id="tmessageid"></textarea></td>
</tr>
<tr>
<td align="right" id="one"></td>
<td><input type="submit" name="submit" id="submit" value="Submit Comment"></td>
</tr>
</table>
</form>
</body>
</html>
Comment.php looks like tihs:
<?php
if(isset($_POST['submit']))
{
$name=$_POST['namename'];
$message=$_POST['message'];
$insert=mysql_query("insert into commenttable
(name, message)values
('$name','$message')")or die(mysql_error());
header("Location:index.php");
}
?>
and I get No database selected when I submit. My database is "comments" with a table "commenttable" and "name" and "message" inside it.