1

I'm submitting a form in POST method which initially sends an email with the form informations. The issue here is that when filling the email input and trying to var_dump it, all I get is string(0) "" and I can't figure out why.

Here's the form :

 <form id="form" class="form" name="postuler" method="post" action="/sources/site/composants/recrutement/receive.php" enctype="multipart/form-data" novalidate>

    <div style="width:auto; float:left; padding-left:15px;">
            <label for="nom">Votre nom <span class="required">*</span></label>
            <input type="text" class="nom" placeholder="ex: Doe" name="nom" id="nom" maxlength="40" required="required"/>
            <br/> 

      <div class="not-hidden">
       <label for="mail">Adresse e-mail <span class="required">*</span></label>
       <input type="email" class="email" placeholder="ex: [email protected]" name="mail" id="email" maxlength="40" required="required"/>
      </div>
      <div class="hidden-fields">   
            <label for="prenom">Votre prénom <span class="required">*</span></label>
            <input type="text" class="prenom" placeholder="ex: John" name="prenom" id="nom" maxlength="40"  required="required"/>
       </div>
   </div>
   <div style="width:auto; float:left; padding-left:15px">    

        <div class="not-hidden">
            <label for="prenom">Votre prénom <span class="required">*</span></label>
            <input type="text" class="prenom" placeholder="ex: John" name="prenom" id="nom" maxlength="40" required="required"/>
        </div>

            <div class="hidden-fields"> 
            <label for="mail">Adresse e-mail <span class="required">*</span></label>
            <input type="email" class="email" placeholder="ex: [email protected]" name="mail" id="email" maxlength="40" required="required"/> 
            </div>
            <input type="submit" name="upload" id="envoyez" value="Valider"  class="postu"/>
        </form>

I tried to debug the mail variable with :

if(isset($_POST['mail'])){
    var_dump($_POST['mail']);
} else {
    echo 'Did not receive var, sorry';
}
6
  • A placeholder won't send a value, you need to send some actual value. Commented Sep 3, 2017 at 13:53
  • I edited the post, I actually fill the input, and get an empty string although Commented Sep 3, 2017 at 13:56
  • Within the same form, you have multiple ones with name="mail" and it'll just pick the last one, as it overwrites the other. Commented Sep 3, 2017 at 13:57
  • You have 2 inputs with the name of mail. Either change one of the names or rename them to mail[] so that php can pick up the array values. Commented Sep 3, 2017 at 13:57
  • Whats your other page name? Also show your <form> opening tag Commented Sep 3, 2017 at 14:16

2 Answers 2

1

From the code that you posted i see that the problem could be that your form has two input fields with same name, you have to have different names for them. Maybe you just thought it's something like input type "radio". Look here for correct information how to deal with forms and their names: All information you need about forms and their inputs

But also the question is why you haven't posted where the form begins because we can understand your code wrong or something. Because you form closing tag is inside a div which has no form start tag.

Sign up to request clarification or add additional context in comments.

Comments

0

That's because you'r using duplicated input name mail

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.