{HELP} I will change the Radio Button Link in a Form, but it does not arrive in the email

Asked

Viewed 54 times

-1

I have a problem in a form, I need when choosing a radio it change the link to where the information goes,that I could, but in the email is not getting the form information
Someone can help me?

Filing cabinet enviar.php

<!-- language: php -->

    <?php

        <?php
$ipaddress = $_SERVER['REMOTE_ADDR'];
$nome  = $_POST['nome'];
$email = $_POST['email'];
$mobile = $_POST['mobile'];
$info = getdate();
$date = $info['mday'];
$month = $info['mon'];
$year = $info['year'];
$hour = $info['hours'];
$min = $info['minutes'];
$sec = $info['seconds'];
$current_date = "$date/$month/$year - $hour:$min:$sec";
$exibir_apos_enviar='mensagem-enviada.html';


mail("[email protected]","Orçamento Alopecia","Nome: $nome \n\n Email: $email \n\n Telefone: $mobile \n\n IP: $ipaddress \n\n Contato em: $current_date");
echo "<script>window.location='$exibir_apos_enviar'</script>";
?>

<script type="text/javascript">
     jQuery(function($){
        $('.gender').click(function(){
        var volume = $(this).val();

        if (volume == "alopecia") {
                $('#form-action').attr('action', 'http://www.eternus.com.br/ebook-7-segredos-uso-protese-capilar/enviando-alopecia.php');
        }
        else if (volume == "calvice") {
            $('#form-action').attr('action', 'http://www.eternus.com.br/ebook-7-segredos-uso-protese-capilar/enviando-calvice.php');
        }
		else if (volume == "quimio") {
            $('#form-action').attr('action', 'http://www.eternus.com.br/ebook-7-segredos-uso-protese-capilar/enviando-quimio.php');
        }
        else if (volume == "outros") {
            $('#form-action').attr('action', 'http://www.eternus.com.br/ebook-7-segredos-uso-protese-capilar/enviando-outros.php');
        }
    });
});
</script>
<form role="form" method="POST"  action="#" id="form-action">
<div class="form-group">
<label>Nome Completo</label>
<input class="form-control input-lg" name="nome" id="nome" type="text" placeholder="Coloque Seu Nome Completo" required>
</div>
<div class="form-group">
<label>Email</label>
<input class="form-control input-lg" name="email" id="email" type="text" placeholder="Coloque seu email" required>
</div>
<div class="form-group">
<label>Celular/Whatsapp</label>
<input class="form-control input-lg" name="mobile" id="mobile" type="text" placeholder="Coloque o Numero do Whatsapp">
</div>
<br>
<label>Para Qual Solução Será usado o eBook?</label>
<br>
  <input type="radio" name="gender" value="alopecia" class="gender">Alopecia<br>
  <input type="radio" name="gender" value="calvice" class="gender"> Calvice<br>
  <input type="radio" name="gender" value="quimio" class="gender"> Quimioterapia<br>  
<input type="radio" name="gender" value="outros" class="gender"> Outros<br>
     <br>



<div class="form-group last">
       <input type="submit" class="btn btn-warning btn-block btn-lg" name="aderir" id="aderir" value="Enviar" >
     
</div>
<p class="re-assure">Nós Não Compartilhamos seu Email. Sem spam. </p>
</form>

  • Each radio will send the data of your form by $_POST to an archive .php different, that’s it?

  • that’s exactly what

1 answer

0


If I understand correctly, each radio send the data from your form for $_POST to a file. different php, that is, all you need to do is change your javascript/jquery as follows:

<script type="text/javascript">
     jQuery(function($){
        $('.gender').click(function(){
        var volume = $(this).val();

        if (volume == "other") {
                $('#phpcontactform').attr('action', 'http://www.site.com.br/enviando0.php');
        }
        else if (volume == "male") {
            $('#phpcontactform').attr('action', 'http://www.site.com.br/enviando1.php');
        }
        else if (volume == "female") {
            $('#phpcontactform').attr('action', 'http://www.site.com.br/enviando2.php');
        }
    });
});
</script>

With this he will change the action of the form whenever you change the radio and send the data of your form to another file according to the radio selected.

  • Thanks man, this going to target php however is not getting in the email the name data, email and phone, this email arriving without the data

  • I edited the question for you to see how I did, can you help me man?

  • gives a var_dump($_POST) in your file enviar.php

  • what would that be?

  • to check if the form data is arriving in your file enviar.php through the post

  • I don’t know how to do this rsrsrs

  • $name=$_POST['name']; $email=$_POST['email']; $phone=$_POST['phone']; $message=$_POST['message']; $display_apos_send='sent-successfully.html';

  • I will edit the question with the code I have until now

  • before the $nome=$_POST['nome']; you put var_dump($_POST);

  • put but did not arrive in the email in the same way

  • I forgot one more part var_dump($_POST);exit(); , this way will cause the code to stop and appear if the data is coming

  • got it.... thanks man

Show 7 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.