Skip to content

Instantly share code, notes, and snippets.

@modos189
Created April 5, 2013 15:31
Show Gist options
  • Save modos189/5320221 to your computer and use it in GitHub Desktop.
Save modos189/5320221 to your computer and use it in GitHub Desktop.
не забудь базу данных подготовить
<?php
if (!empty($_GET['name']) and !empty($_GET['mail']) and !empty($_GET['text'])) {
$hostname = 'localhost';
$username = 'root';
$password = 'root';
$db = 'test';
// Подключаемся к серверу MySQL
$db = mysql_connect($hostname, $username, $password)
or die('connect to database failed');
// Выбираем нужную БД
mysql_select_db($db)
or die('db not found');
// Формируем и отправляем запрос, результат запишется в $result
$query = 'INSERT INTO `guest` (`name` ,`mail` ,`text`) VALUES ($_GET[\'name\'], $_GET[\'mail\'], $_GET[\'text\']);';
$result = mysql_query($query)
or trigger_error(mysql_errno() . ' ' .
mysql_error() . ' query: ' . $sql);
mysql_close($db);
}
?>
<form>
Имя: <input name="name" type="text"><br>
Мыло: <input name="mail" type="text"><br>
Сообщение: <textarea name="text"></textarea><br>
<input type="submit"><br>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment