-1
I am making a form which as soon as it is sent, it should send an SMS thanking for the contact to the number in which it was informed in the form.
I have the following form:
<form action="processa.php" method="post">
<div>
<label for="nome">Nome:</label>
<input type="text" id="nome" name="nome" />
</div>
<div>
<label for="email">E-mail:</label>
<input type="email" id="email" name="email" />
</div>
<div>
<label for="telefone">Telefone:</label>
<input type="tel" id="telefone" name="telefone" />
</div>
<div>
<label for="msg">Mensagem:</label>
<textarea id="msg" name="mensagem"></textarea>
</div>
<div class="button">
<button type="submit">Enviar sua mensagem</button>
</div>
</form>
File - processes.php
<?php
$email = addslashes($_POST['email']);
$nome = addslashes($_POST['nome']);
$telefone = addslashes($_POST['telefone']);
$mensagem = addslashes($_POST['mensagem']);
$destinatario = "[email protected]";
$assunto = "Nova solicitação de contato";
$msg = "
Você recebeu a seguinte solicitação de contato:
-------------------------------------
Nome: $nome
Email: $email
Telefone: $telefone
Mensagem: $mensagem ";
$headers = "MIME-Version: 1.1\r\n";
$headers .= "Content-type: text/plain; charset=UTF-8\r\n";
$headers .= "From: NOME DO CONTATO <[email protected]>\r\n"; // remetente
$headers .= "Return-Path: [email protected]\r\n"; // return-path
$envio = mail($destinatario, $assunto, $msg, $headers);
if($envio){
header ("location: sucesso.html");
}else{
echo "A mensagem não pode ser enviada";
}
?>
The form when it is filled out, it sends me an email with the data that was entered, and then redirects to sucesso.html
.
I would like when the person submits the form, to send an SMS to the person who completed the form.
HTTP API - Example of use
http://portal.gtisms.com:2000/gti/API/[email protected]&senha=teste&msg=Obrigado+Por+Entrar+Em+Contato&n=11984010101&id=0001
How to adapt the php script for him to make a request for the HTTP API sending an SMS to the number provided? The number ($telephone) shall be assigned to the parameter
n=
.
I would like an example =(
This API I never used, but I used this https://www.nexmo.com/. For this you can use Curl, http://codular.com/curl-with-php
– Miguel
I didn’t understand what the doubt would be, you can use the CURL as mentioned. If you want to reduce the response time you can use the
exec
with a CURL ignoring the answer, so the page will be processed without waiting for Curl. Anyway, the question was half vacant.– Inkeliz
Try file_get_contents passing this url.
– Antonio Alexandre
If you really need to dispatch the answer immediately and continue processing the script after that, read the vcampitelli response here at Stack Overflow: http://stackoverflow.com/questions/15273570/continue-processing-php-after-sending-http-response
– Antonio Alexandre
Thanks friends, I’ll take a look to see if I can do something =/
– Alexandre Lopes