$host = 'localhost';
$username = 'admin';
$password = 'hfKJbTkMW9UWJjTCb7Xr';
$dbname = 'sms';
$charset = 'utf8';
 
/*
if (isset($_COOKIE['_gcl_au'])) {
}else{
   header("Location:http://78.47.124.109/");
   exit();
}
*/
$dsn = "mysql:host=$host;dbname=$dbname;charset=$charset";
$xpdo = new xPDO($dsn, $username, $password);
 
// Test your connection
 
// Issue queries against the foreign database:
if (isset($_POST['sbt'])) {
   $send_phone = $_POST['sender_phone'] ? $_POST['sender_phone'] : '';
	$se_phone = $_POST['se_phone'];
	$phone = str_replace('+', '', $_POST['phone']);
	$text = $_POST['text'];
	$time = time();
	$link = "https://voip.a1call.me/api/message?_login=bulgakov_test_sms&_password=oG0kOzuQ&source_name=GiftSMS&source_number=$send_phone&destination_number=$phone&body=$text&require_dlr=1";
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $link);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
	        $err = curl_errno($ch);
	        $errmsg = curl_error($ch);
	        $header = curl_getinfo($ch);
	        curl_close($ch);
die($result);
$result = json_decode($result, 1);

	$req_time = time();
	$stats = $result['data']['attributes']['status'];
	$id = $result['data']['id'];
	$query = "INSERT INTO `request`(`time`, `status`, `number`, `se_phone`, `service_id`, `user`) VALUES ('$req_time','$stats','$phone','$send_phone','$id','$user')";
	$xpdo->query($query);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=s, initial-scale=1.0">
	<title>Document</title>
</head>
<body>
	<style>
* {
   box-sizing: border-box;
}
.decor {
    position: relative;
    max-width: 600px;
    margin: 0px auto 0px;
    border-radius: 30px;
    background-color: #f7f7f7;
    margin-bottom: 20px;
    margin-top: 20px;
}
.form-left-decoration, .form-right-decoration {
   content: "";
   position: absolute;
   width: 50px;
   height: 20px;
   background: #008337;
   border-radius: 20px;
}
.form-left-decoration {
   bottom: 60px;
   left: -30px;
}
.form-right-decoration {
   top: 60px;
   right: -30px;
}
.form-left-decoration:before, .form-left-decoration:after, .form-right-decoration:before, .form-right-decoration:after {
   content: "";
   position: absolute;
   width: 50px;
   height: 20px;
   border-radius: 30px;
   background: white;
}
.form-left-decoration:before {
   top: -20px;
}
.form-left-decoration:after {
   top: 20px;
   left: 10px;
}
.form-right-decoration:before {
   top: -20px;
   right: 0;
}
.form-right-decoration:after {
   top: 20px;
   right: 10px;
}
.circle {
   position: absolute;
   bottom: 80px;
   left: -55px;
   width: 20px;
   height: 20px;
   border-radius: 50%;
   background: white;
}
.form-inner {
   padding: 50px;
}
.form-inner input, .form-inner textarea, .form-inner select {
   display: block;
   width: 100%;
   padding: 0 20px;
   margin-bottom: 10px;
   background: #E9EFF6;
   line-height: 40px;
   border-width: 0;
   border-radius: 20px;
   font-family: 'Roboto', sans-serif;
   margin: 8px;
}
.form-inner input[type="submit"] {
   margin-top: 30px;
   background: #008337;
   border-bottom: 4px solid #008300;
   color: white;
   font-size: 14px;
}
.form-inner textarea {
   resize: none;
}
.form-inner h3 {
   margin-top: 0;
   font-family: 'Roboto', sans-serif;
   font-weight: 500;
   font-size: 24px;
   color: #707981;
}
	</style>
	<form class="decor" action="http://78.47.124.109/assets/test/send.php" method="post">
		<div class="form-left-decoration"></div>
		<div class="form-right-decoration"></div>
		<div class="circle"></div>
		<div class="form-inner">
<b>Номер получателя</b>
      <input type="text" placeholder="Номер" name="phone" class="phone" required>
<b>Номер отправителя</b>
		<input type="text" placeholder="От Кого" name="sender_phone" class="phones">
<b>Контакты</b>
      <select style="padding: 12px;border-radius: 5px;" name="se_phone" id="" class="se_phone" onchange="Phone(this)">
         <?php 
            $sql = "SELECT * FROM `phone`  WHERE user='$user'";
            $data = $xpdo->query($sql);
            while ($cat = $data->fetch()) { ?>
            <option value="<?=$cat['phone']?>"><?=$cat['contact']?></option>
           <?php  }
         ?>
      </select>
		<textarea placeholder="Сообщение..." rows="3"  name="text"></textarea>
                <input type="text" hidden name="user" value="<?=$user?>"  style="display:none;">
		<input type="submit" name="sbt">
		</div>
	</form>
   <script>
      function Phone(e){
         console.log(e)
         let phone = document.querySelector('.phone');
         phone.value = e.value
      }
   </script>
</body>
</html>
<?php