Follow along with the video below to see how to install our site as a web app on your home screen.
Бележка: This feature may not be available in some browsers.
<?php
session_start();
mysql_connect("localhost","user","password") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());
$user = $_GET['username'];
// да речем сме влезни в този адрес: addkomentar.php?username=stefan
echo "<form method='POST'>";
echo "<textarea name='message'></textarea><br>";
echo "<input type='submit' name='submit' value='Добави'>";
echo "</form>";
if (isset($_POST['submit']))
{
$message = htmlspecialchars($_POST['message']);
$ot = $_SESSION['username'];
if (!empty($message))
{
mysql_query("INSERT INTO comments (ot,za,komentar) VALUES ('$ot','$user','$message')") or die(mysql_error());
mysql_query("INSERT INTO message (ot,za,message) VALUES ('System','$user','Вие получихте нов коментар от $ot')") or die(mysql_error());
echo "Коментарът е добавен успешно.";
}
else
{
echo "Не сте въвели съобщение";
}
?>