+-----------------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+------------------+------+-----+---------+----------------+
| id_comentariu | int(10) unsigned | | PRI | NULL | auto_increment |
| nume_utilizator | text | YES| |NULL | |
| adresa_email | text | YES| | NULL | |
| comentariu | text | YES | | NULL | |
+-----------------+------------------+------+-----+---------+----------------+
Here you have the mysql commands to create table "comentarii":
create table comentarii
(id_comentariu int unsigned default '0' not null auto_increment,
nume_utilizator text,
adresa_email_text,
comentariu text,
primary key(id_comentariu),
unique(id_comentariu),
index(id_comentariu));
This is the code for guestbook.php:
<html>
<head><title>My Guestbook</title></head>
<body>
<p><b>My Guestbook</b></p>
<?
mysql_connect("localhost","user","password");
mysql_select_db("your_database");
$sqlComentarii = "select * from comentari";
$resursaComentarii = mysql_query($sqlComentarii);
while($row2 = mysql_fetch_array($resursaComentarii))
{
print '<div style="width:400px; border:1px solid #ffffff; background-color:#f9f1e7; padding:5px"> <a href="mailto:'.$row2['adresa_email'].'">'.$row2['nume_utilizator'].'</a><br>
'.$row2['comentariu'].'</div>';
}
?>
<br>
<div style="width:400px; border:1px solid #632415; background-color:#f9f1e7; padding:5px;">
<b>Add your comment:</b>
<hr size="1">
<form action="add_post.php" method="POST">
Nume: <input type="text" name="nume_utilizator">
E-mail: <input type="text" name="adresa_email"><br><br>
Comentariu:<br>
<textarea name="comentariu" cols="45"></textarea><br><br>
<center><input type="submit" value="Adauga"></center>
</form>
</div>
</td>
</body>
</html>
This is the code for add_post.php:
<?
if($_POST['nume_utilizator'] == "" || $_POST['adresa_email'] == "" || $_POST['comentariu'] == "")
{
print "Trebuie sa completezi toate campurile!";
exit;
}
mysql_connect("localhost","user","password");
mysql_select_db("your_database");
$nume = strip_tags($_POST['nume_utilizator']);
$mail = strip_tags($_POST['adresa_email']);
$comentariu = strip_tags($_POST['comentariu']);
$sql = "insert into comentarii(nume_utilizator,adresa_email,comentariu) values('".$nume."','".$mail."','".$comentariu."')";
mysql_query($sql);
header("location: guestbook.php");
?>
I hope this will be useful to you. If you have any questions or problemns do not esitate to ask me.

