Code:
<?php
if (isset($_POST['id']) {
$conn = mysql_connect("localhost", "db", "pass") or die ("Not connected" . mysql_error());
$select_db = mysql_select_db("comments", $conn);
if (!$select_db)
echo "Error";
else
$query = mysql_query("INSERT * INTO comments (name, comment) VALUES ($_POST['name'], $_POST['comment'])";
if (!$query)
echo "Error";
}
else {
echo "<form method='POST' action=" . $PHP_SELF . "><input type='hidden' name='id' >
<p>Vase ime: <input type='text' name='name' size='20'></p>
<p>Komentar:<textarea rows='2' name='comment' cols='20'></textarea></p>
<p><input type='submit' value='Submit' name='B1'><input type='reset' value='Reset' name='B2'></p>
</form>";
$query = mysql_query("SELECT * FROM comments ORDER BY id DESC");
while ($row = mysql_fetch_array($query)) {
echo "Name: " .$row['name'] . "<br/>";
echo "Comment: " . $row['comment'] ."<br/>";
}
?>
Trebas ovo uraditi.
Moras koristiti neki jezik kao sto je PHP ili ASP.
Pozdrav
[Ovu poruku je menjao emranonline dana 13.04.2007. u 15:48 GMT+1]