-1
Hello!
I am a beginner in PHP and am putting together a form to receive data through POST, and print them into a custom URL. The purpose of the form is to register leads on a third CRM platform, which only accepts the inclusion of data in this way.
The structure of the URL is as follows: https://crm4u.azurewebsites.net/api/Android/PutLead/< NAME >;< E-MAIL >;< TELEPHONE >;< REMARKS >/281/739164197
Apparently I’m able to execute the script and manipulate the address, but I was only able to do this with the header function("Location").
Form:
<form id="formulario" action="mail_lead_santos.php" method="post">
Nome: <input type="text" id="nome" name="nome"><br>
E-mail: <input type="text" id="email" name="email"><br>
Telefone: <input type="tel" id="telefone" name="telefone"><br>
Motivo: <select id ="observacoes" name="observacoes">
<option value="Opção 1">Opção 1</option>
<option value="Opção 2">Opção 2</option>
<option value="Opção 3">Opção 3</option>
</select><br>
<input id="enviar" name="enviar" type="submit" value="Enviar!">
</form>
mail_lead_santos.php
<?php
$nome = $_POST['nome'];
$email = $_POST['email'];
$telefone = $_POST['telefone'];
$observacoes = $_POST['observacoes'];
$final = 'Location: https://crm4u.azurewebsites.net/api/Android/PutLead/'.$nome.';'.$email.';'.$telefone.';'.$observacoes.';'.'/281/739164197';
header($final);
?>
With this, after completing the form, naturally the user falls into this final URL. How could I perform this function through the form, but keep it on the fill-in page? I understand that the best way is perhaps through jquery/ajax, but how to work together with the header function?
Thank you!
Considering that the third platform validates the data, I believe that, in your scenario, the best option would be to make a GET request with jquery same. No need to reload or redirect the fill page.
– mbissonho
Right! I don’t know much about jquery, but I’m testing some things - posted as response in the main message.
– Luiz Francisco Fonseca