There is a html record form as well as its handler that records the entered data in the mysql and displays it on the screen.
The data is entered into the database and the information from the form is displayed on the html page, but there is a problem with the output of information from the select element (drop-down list), it is necessary that the selected word be displayed, and not its code.
Record Form
<form class="contact_form" action="message.php" method="post" name="contact_form"> <br> <ul> <li> <h2>Введите данные для записи на прием</h2> <span class="required_notification">* Поля, обязательные для заполнения</span> </li> <li> <label for="name">Имя:</label> <input type="text" name="name" required placeholder="Ваше имя"> </li> <li> <label for="surname">Фамилия:</label> <input type="text" name="surname" required placeholder="Ваша фамилия"> </li> <li> <label for="middlename">Отчество:</label> <input type="text" name="middlename" required placeholder="Ваше отчество"> </li> <li> <label for="policynumber">Номер полиса:</label> <input type="text" name="policynumber" required placeholder="Ваш номер полиса"> </li> <li> <label for="doc">Выберите врача:</label> <select name="doctor"> <option value="1" selected>Терапевт</option> <option value="2">Стоматолог</option> </select> </li> <li> <label for="dateofbirthr">Дата рождения:</label> <input type="date" name="dateofbirth" required placeholder="Дата рождения"> </li> <li> <label for="dateofadmission">Выберите дату приема:</label> <input type="date" name="dateofadmission" required placeholder="Дата приема"> </li> <li> <button class="submit" type="submit">Отправить</button> </li> </ul> </form> Form handler (did not copy it completely, missed the moment with connecting to the database)
try { switch ($doctor) { case 1: $table = "therapist"; break; case 2: $table = "dentist"; break; } $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $dbh->beginTransaction(); $sth = $dbh->prepare("INSERT INTO `$table` (name, surname, middlename, dateofbirth, policynumber, dateofadmission) VALUES (:name, :surname, :middlename, :dateofbirth, :policynumber, :dateofadmission)"); // Для вставки параметров в запрос PDO есть специальные методы $sth->bindParam(':name', $name, PDO::PARAM_STR); $sth->bindParam(':surname', $surname, PDO::PARAM_STR); $sth->bindParam(':middlename', $middlename, PDO::PARAM_STR); $sth->bindParam(':dateofbirth', $dateofbirth, PDO::PARAM_STR); $sth->bindParam(':policynumber', $policynumber, PDO::PARAM_INT); $sth->bindParam(':dateofadmission', $dateofadmission, PDO::PARAM_STR); $sth->execute(); } catch (Exception $e) { $dbh->rollBack(); } print (" Ваше имя: " . $_POST['name'] . ".<br>\n"); print (" Ваша фамилия: " . $_POST['surname'] . ".<br>\n"); print (" Ваше отчество: " . $_POST['middlename'] . ".<br>\n"); print (" Дата рождения: " . $_POST['dateofbirth'] . ".<br>\n"); print (" Номер полиса: " . $_POST['policynumber'] . ".<br>\n"); print (" Дата приема: " . $_POST['dateofadmission'] . ".<br>\n"); print (" Лечащий врач: " . $_POST['doctor'] . ".<br>\n"); { $dbh->commit(); } } ?> Here is what is displayed on the screen (note the last line) 
print- useecho- this construction supports the operatorand so on(and so on), that is,echo $a, $b, $c;- listing of arguments separated by comma, for the concatenation point$a.$b.$cand works faster thanprint. And I recommend usingmysqliwith themysqlnddriver. - And