F
F
Faber Estello2016-07-04 12:16:21
Layout
Faber Estello, 2016-07-04 12:16:21

What is the principle of sending an order form to the phone in SMS?

What is the principle of sending an order form to the phone in SMS? What is used, how is the usual js type different

$.ajax({
                          url: 'contacts.php',
                          type: 'post',
                          data: str
                      }).done(function(msg){

                          if(msg === "OK"){
                              console.log('ok');
                          }else {
                              ...
                          }                    

                      }).always(function(){
                          ...                 
                      });

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alex Glebov, 2016-07-04
@senselessV7

only php file
smsc.ru changes - sending service

<?php

$name = @ trim ($_POST['name']);
$tel = @ trim ($_POST['tel']);

function send_sms($number, $text, $cost=0) {
    $login = 'aaaaa';     // Логин в SMSC
    $password = 'aaaaaa';   // Пароль в SMSC
    $sender = 'aaaa';    // Имя отправителя
    
    // Подготовим запрос
    $Prepare = "http://smsc.ru/sys/send.php?login={$login}&psw={$password}&phones={$number}&mes={$text}";
    $Request = file_get_contents($Prepare . "&cost={$cost}&fmt=1&charset=utf-8&sender={$sender}");
    
    // Обработка ответа
    $Response = explode(',', $Request);
    if(isset($Response[1]) && isset($Response[0])) {
        // Узнать цену
        if($cost) {return $Response[0]; }
        // SMS удачно дошло
        if($Response[1] == '1') { return True; }
    }
     
    return False;
     
}
// Отправляем сообщение
$send = send_sms(+79999999999, "Новая заявка: $name $tel");
if($send == True) {
    header('Location:index.html#senks');
}
 

?>

N
Neoliz, 2016-07-04
@timofeydeys

SMS is sent from the server. You need to either raise your own server, or use ready-made services (they are usually paid). Those. pass data to the server, as you do with a request. And the server is already sending

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question