12345678910111213141516171819202122232425262728293031323334 |
- <?php
- $host = "provalgk.beget.tech";
- $username = "provalgk_user";
- $password = "Qwer123.";
- $database = "provalgk_user";
- $review = $_POST["review"];
- $rating = $_POST["rating"];
- $mysql = new mysqli($host, $username, $password, $database);
- if($mysql->connect_error){
- die("Ошибка подключения". $mysql->connect_error);
- }
- session_start();
- $id = $_SESSION['id'];
- $query = "INSERT INTO reviews (review, rating, id_user) VALUES ('$review', '$rating', '$id')";
- $result = $mysql->query($query);
- if(!$result){
- echo "Что то не так" . $mysql->error;
- }
- else{
- session_start();
- $message = "Пользователь ".$_SESSION['login']. " оставил отзыв: ".$review.". Оценив сайт на " .$rating. "звёзд";
- $query = "SELECT * FROM Login Where role = 1";
- $result = mysqli_query($mysql, $query);
- While($rivews = mysqli_fetch_assoc($result)){
- $from = "provalenkoludmila@gmail.com";
- $subject = "Новый отзыв на сайте";
- $subject = "=?utf-8?B?".base64_encode($subject)."?=";
- $headers = "From: $from\r\nReply-to: $from\r\nContent-type: text/html; charset=utf-8\r\n";
- mail($rivews['email'], $subject, $message, $headers);
- }
- echo "<script>window.location.href = 'indexforuser.html';</script>";
- }
- ?>
|