Good afternoon, good people, there was a problem to solve on a site, something that had not yet moved.
It is as follows, on the page I have a form where the person can register. By registering, I'll send you an email confirming this registration.
Now, let's start using SMS too, that is, the person registers, receives an email and an SMS confirming (company rules). But my manager wants the SMS to arrive after about 5 min that the person has registered on the site.
At the moment, I'm sending the SMS right away, but he wants it done the way he said it.
Can anyone help me?
Note: I submit the form on the same page as the insert.
function sendSms(){
$nome = explode(" ",$_POST['txtNome']); // pega o nome via post , e joga cada palavra em um array
$corrigir = array(' ','-','(',')','{','}','/',' ');// array que elimina caractres do telefone ,deixando somente os numeros
$corpoSMS = 'SKY HDTV:Caro(a).'$nome[0].',informamos que seus dados foram enviados para nosso dpt de cadastros.Dentro de 24h,entraremos em contato com maiores informacoes'; //monta o corpo do sms , mantendo o limite de 160 caracteres.
$tel = str_replace($corrir,'',$_POST['txtCel']);
$msg = str_replace(' ','+',$corpoSMS);
//código da página enviapost.php
$dados_post = array(
"" => $tel,
"?message=" => $msg,
);
$context = stream_context_create(array(
'http' => array(
'method' => 'GET',
'header' => array(
'Content-Type: application/x-www-form-urlencoded'),
'content' => http_build_query($dados_post)
)
)
);
$host = 'https://meuservidordesms.com.br/'.$tel.'?message='.$msg;
$result = file_get_contents($host,false,$context);
if(preg_match("/SUCESSO/", $result)){
echo ' <script type="text/javascript">
alert("SMS enviado com sucesso!");
</script>';
} else {
echo '<script type="text/javascript">alert("Erro enviar o SMS.<br>");</script>';
}
}// FUNCAO QUE ENVIA O SMS AO CLIENTE.