Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form method="POST" action="mysql.php" class="callback form-order">
- <div class="row">
- <div class="col-md-3">
- <label>
- <p>Имя:</p>
- <input type="text" name="name" placeholder="Имя" required>
- </label>
- </div>
- <div class="col-md-3">
- <label>
- <p>Фамилия:</p>
- <input type="text" name="surname" placeholder="Фамилия" required>
- </label>
- </div>
- <div class="text-center">
- <button class="button">Отправить</button>
- </div>
- <?php
- $method = $_SERVER['REQUEST_METHOD'];
- //Script Foreach
- $c = true;
- if ( $method === 'POST' ) {
- $project_name = trim($_POST["project_name"]);
- $admin_email = trim($_POST["admin_email"]);
- $form_subject = trim($_POST["form_subject"]);
- foreach ( $_POST as $key => $value ) {
- if ( $value != "" && $key != "project_name" && $key != "admin_email" && $key != "form_subject" ) {
- $message .= "
- " . ( ($c = !$c) ? '<tr>':'<tr style="background-color: #f8f8f8;">' ) . "
- <td style='padding: 10px; border: #e9e9e9 1px solid;'><b>$key</b></td>
- <td style='padding: 10px; border: #e9e9e9 1px solid;'>$value</td>
- </tr>
- ";
- }
- }
- } else if ( $method === 'GET' ) {
- $project_name = trim($_GET["project_name"]);
- $admin_email = trim($_GET["admin_email"]);
- $form_subject = trim($_GET["form_subject"]);
- foreach ( $_GET as $key => $value ) {
- if ( $value != "" && $key != "project_name" && $key != "admin_email" && $key != "form_subject" ) {
- $message .= "
- " . ( ($c = !$c) ? '<tr>':'<tr style="background-color: #f8f8f8;">' ) . "
- <td style='padding: 10px; border: #e9e9e9 1px solid;'><b>$key</b></td>
- <td style='padding: 10px; border: #e9e9e9 1px solid;'>$value</td>
- </tr>
- ";
- }
- }
- }
- $message = "<table style='width: 100%;'>$message</table>";
- function adopt($text) {
- return '=?UTF-8?B?'.Base64_encode($text).'?=';
- }
- $headers = "MIME-Version: 1.0" . PHP_EOL .
- "Content-Type: text/html; charset=utf-8" . PHP_EOL .
- 'From: '.adopt($project_name).' <'.$admin_email.'>' . PHP_EOL .
- 'Reply-To: '.$admin_email.'' . PHP_EOL;
- mail($admin_email, ado
- pt($form_subject), $message, $headers );
- ?>
- <?php
- //Параметры подключения в БД
- $host = "11"; //имя хоста
- $database = "11"; //имя базы
- $user = "11"; //пользователь
- $password = "11"; //пароль
- $dbtable = "Users"; //таблица
- if (isset($_POST['name'])){
- //переменные с формы
- $name = strip_tags(trim($_POST['name']));
- $surname = strip_tags(trim($_POST['surname'];
- $secondname = strip_tags(trim($_POST['secondname'];
- $phone = strip_tags(trim($_POST['phone'];
- $birthdate = strip_tags(trim($_POST['birthdate'];
- $birhtplace = strip_tags(trim($_POST['birhtplace'];
- $citizenship = strip_tags(trim($_POST['citizenship'];
- $doc = strip_tags(trim($_POST['doc'];
- $docid = strip_tags(trim($_POST['docid'];
- $docpublish = strip_tags(trim($_POST['docpublish'];
- $docdate = strip_tags(trim($_POST['docdate'];
- $regterm = strip_tags(trim($_POST['regterm'];
- $comment = strip_tags(trim($_POST['comment'];
- $date = date("Y-m-d");
- $time = date("H:i:s")
- //установим соединение с бд
- $link = mysqli_connect($host, $user, $password, $database)
- or die("Ошибка " . mysqli_error($link));
- $sql = "INSERT INTO ".$dbtable." (order_date, order_time, name, surname, second_name, phone, birth_date, birht_place, citizenship, doc, doc_id, doc_publish, doc_date, term) VALUES ('$date', '$time', '$name', '$surname', '$secondname', '$phone', '$birthdate', '$birhtplace', '$citizenship', '$doc', '$docid', '$docpublish', '$docdate', '$regterm', '$comment')"
- //внесём данные с формы в БД
- $res = mysqli_query($sql) or trigger_error(mysqli_error()." in ". $sql);
- mysqli_close($link);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement