[ Поиск ] - [ Пользователи ] - [ Календарь ]
Полная Версия: INSERT INTO в PHP
алекс2015
Подскажите как тут применить INSERT INTO? А потом применить SELECT?

report.html

<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="../css/style.css">
<title>Шаблон</title>
</head>
<body>
<div id="wrapper">
<p>Расскажите историю о похищении вас пришельцами:</p>
<form method="post" action="report.php">
<label for="firstname" >Имя:</label>
<input type="text" id="firstname" name="firstname" style="margin-left:178px;" /><br />
<label for="lastname">Фамилия:</label>
<input type="text" id="lastname" name="lastname" style="margin-left:145px;" /><br />
<label for="email">Ваш адрес электронной почты:</label>
<input type="text" id="email" name="email" /><br />
<label for="whenithappend">Когда это произошло:</label>
<input type="text" id="whenithappend" name="whenithappend" style="margin-left:63px;" /><br />
<label for="howlong">Как долго вы отсутствовали:</label>
<input type="text" id="howlong" name="howlong" style="margin-left:16px;" /><br />
<label for="howmany">Сколько их было:</label>
<input type="text" id="howmany" name="howmany" style="margin-left:92px;" /><br />
<label for="aliendiscription">Опишите их:</label>
<input type="text" id="aliendiscription" name="aliendiscription" size="32" style="margin-left:72px;" /><br />
<label for="whatthedid">Что они делали с вами?</label>
<input type="text" id="whatthedid" name="whatthedid" size="32" style="margin-left:0px;" /><br />
<label for="fangspotted">Видели ли вы мою собаку?</label>
Да<input id="fangspotted" name="fangspotted" type="radio" value="yes" />
Нет<input id="fangspotted" name="fangspotted" type="radio" value="no" /><br />
<img src="../images/dog1.jpg" width="129" height="150" style="margin:5px;" alt="Моя похищенная собака Фэнг."><br />
<label for="other">Дополнительная информация:</label>
<textarea id="other" name="other" /></textarea><br />
<input type="submit" value="Сообщение о похищении" name="submit" />
</form>
</div>

</body>
</html>

style.css

#wrapper{ width:580px; height:520px; border:0px solid #D7FDC6; margin-left:50px; background-color:#D7FDC6; }


report.php

<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>Сообщение</title>
</head>
<body>
<h2>Сообщение</h2>

<?php

$first_name = $_POST['firstname'];
$last_name = $_POST['lastname'];
$when_it_happend = $_POST['whenithappend'];
$how_long = $_POST['howlong'];
$how_many = $_POST['howmany'];
$alien_discription = $_POST['aliendiscription'];
$what_the_did = $_POST['whatthedid'];
$fang_spotted = $_POST['fangspotted'];
$other = $_POST['other'];
$email = $_POST['email'];

$dbc = mysqli_connect('localhost', 'owen', '34598', 'aliendatabase')/* Соединение с базой данных =( Локальный, Имя пользователя, Пароль, База данных)*/
or die('Ошибка соединения с MySQL-сервером');

$query = "INSERT INTO aliens_abduction( first_name, last_name, when_it_happend, how_long, how_many, alien_discription, what_the_did, fang_spotted, other, email)" .
"VALUES('$first_name', '$last_name', '$when_it_happend', '$how_long', '$how_many', '$alien_discription', '$what_the_did', '$fang_spotted', '$other', '$email')";

$result = mysqli_query($dbc,$query)
or die('Ошибка при выполнении запроса к базе данных.');

mysqli_close($dbc);

echo 'Спасибо за заполнение формы.<br />';
echo 'Имя: ' .$first_name.'<br />';
echo 'Фамилия: ' .$last_name.'<br />';
echo 'Вы были похищены ' .$when_it_happend ;
echo ' и отсутствовали в течение '.$how_long.'<br />';
echo 'Количество пришельцев:'.$how_many.'<br />';
echo 'Описание космических пришельцев:'.$alien_discription.'<br />';
echo 'Что они делали? '.$what_they_did.'<br />';
echo 'Фэнг замечен? '.$fang_spotted.'<br />';
echo 'Дополнительная информация:'.$other.'<br />';
echo 'Ваш адрес электронной почты:'.$email;

?>

</body>
</html>

http://SSmaker.ru/8d9149a6/
http://SSmaker.ru/91649961/-это таблица
Быстрый ответ:

 Графические смайлики |  Показывать подпись
Здесь расположена полная версия этой страницы.
Invision Power Board © 2001-2024 Invision Power Services, Inc.