I'm using XAMPP, phpmyadmin and even after correcting it so many times, in output it only shows updated records. The data is not being inserted somehow.
<?php
$name=$_POST['comment'];
$link=mysql_connect('localhost', 'root','' );
mysql_select_db('comments',$link);
mysql_query("insert into comment values('$name'");
echo '<script type="text/javascript">
<!-- window.location = "display1.php" --> </script>';
?>
display1.php
<?php
$link=mysql_connect('localhost', 'root','' );
mysql_select_db('comments',$link);
echo "Updated records:<br>";
$result=mysql_query("select * from comment");
while($row=mysql_fetch_array($result)) {
$tempname=$row['commenting']; echo $tempname."<br>";
}
?>
syntax error in your code while inserting records,
correct code is...
mysql_query("insert into comment(comment_column) values('$name')");
also redirect your page using php header function
don't use javascipt window.location
replace you JavaScript code with...
header("Location:display1.php");
the whole code is...
<?php
$name=$_POST['comment'];
$link=mysql_connect('localhost', 'root','' );
mysql_select_db('comments',$link);
mysql_query("insert into comment(comment_column) values('".mysql_real_escape_string($name)."')");
header("Location:display1.php");
?>
Your insert code need to have the column set
mysql_query("INSERT INTO comment ('commenting') VALUES ('".mysql_real_escape_string($name)."')");
I have added a little better escape method for your query but preferrably not use mysql_* functions. PDO is more secure.