<?php
$servername = "localhost";
$username = "hostarex_order";
$password = "hamzarafael";
$dbname = "hostarex_order";
if(isset($_POST['submit']))
{
    $name = htmlspecialchars($_POST['name']);
    $surname = htmlspecialchars($_POST['surname']);    
    $phone = htmlspecialchars($_POST['phone']);
    $email = htmlspecialchars($_POST['email']);
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}

$sql = "INSERT INTO sifarisler (name, surname, phone, email)
VALUES ('$name', '$surname', '$phone', '$email')";

if (mysqli_query($conn, $sql)) {
    echo "İstəyiniz qeydə alındı! Sizinlə əlaqə saxlanılacaq.";
} else {
    echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}

require 'engine/modules/phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer;

$mail->Host = 'mail.hostarex.com';
$mail->Port = 993;
$mail->SMTPAuth = true; 
$mail->SMTPSecure = 'tls';
$mail->Username = 'form@hostarex.com';
$mail->Password = 'hamzarafael';

$mail->setFrom($_POST['email'], $_POST['name']);
$mail->addAddress('hamza@huseynovs.com');
$mail->addReplyTo($_POST['email'], $_POST['name']);

$mail->isHTML(true);
$mail->Body = '<h1 align=center>Name :' . $_POST['name'] .'<br>Surname: '.$_POST['surname'].'<br>Phone: '.$_POST['phone'].'<br>Email: '.$_POST['Email'];

mysqli_close($conn);

}

?>