<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Data Store</title>
</head>
<body>

<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="sample"; // Table name

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

// get data that sent from form
//$topic=$_POST;
$name=$_POST;
$password=$_POST;

//$datetime=date("d/m/y h:i:s"); //create date time

$sql="INSERT INTO $tbl_name(name, password)VALUES('$name', '$password')";
$result=mysql_query($sql);

if($result){
echo "Successful<BR>";
echo "<a href=dataview.php>View your topic</a>";
}
else {
echo "ERROR";
}
mysql_close();
?>
</body>
</html>

try adding echo to your query, also add the "or die" to your results variable just below the query

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="sample"; // Table name

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$sql="SELECT * FROM $tbl_name ORDER BY id DESC";
// OREDER BY id DESC is order result by descending
$result=mysql_query($sql);
?>
<table width="300" border="1">
<tr>
<td>Id</td>
<td>Name </td>
<td>Password</td>
</tr>
<?php
while($row=mysql_fetch_array($result)){ // Start looping table row
?>
<tr bgcolor="red">
<td style="color:#000; height:25px; font-size:25px;"><? echo $row;?></td>
<td style="color:#000; height:25px; font-size:25px;"><? echo $row; ?></td>
<td style="color:#000; height:25px; font-size:25px;"><? echo $row; ?></td>
</tr>
<?php
// Exit looping and close connection
}
mysql_close();
?>
</table>
</body>
</html>

Above code is my data view page and its still not working Please help sort out the problem
It will be helpful

you havent followed my suggestion. add echo before your sql statements and or die to the same

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.