0

Inside my form, there is this line:

<textarea rows="5" class="form-control" class="text" placeholder="Message" name="comments" required data-validation-required-message="Please enter a message."></textarea>

However, it is not passing to the action php file. The variable $_POST['comments'] echoes empty.

The rest of the values do except this one. Cannot seem to work it out, any help would be great.

Thanks.

Form:

    <form name="sentMessage" id="contactForm" action="mail/contact_me.php" method="post">
                        <div class="row control-group">
                            <div class="form-group col-xs-12 floating-label-form-group controls">
                                <label>Name</label>
                                <input type="text" class="form-control" placeholder="Name" id="name" name="name" required data-validation-required-message="Please enter your name.">
                                <p class="help-block text-danger"></p>
                            </div>
                        </div>
                        <div class="row control-group">
                            <div class="form-group col-xs-12 floating-label-form-group controls">
                                <label>Contact Number</label>
                                <input type="text" class="form-control" placeholder="Contact Number" id="contactNo" name="contactNo" required data-validation-required-message="Please enter a contact number.">
                                <p class="help-block text-danger"></p>
                            </div>
                        </div>
                        <div class="row control-group">
                            <div class="form-group col-xs-12 floating-label-form-group controls">
                                <label>Email Address</label>
                                <input type="text" class="form-control" placeholder="Email Address" id="email" name="email" required data-validation-required-message="Please enter your email address.">
                                <p class="help-block text-danger"></p>
                            </div>
                        </div>
                        <div class="row control-group">
                            <div class="form-group col-xs-12 floating-label-form-group controls">
                                <label>Message</label>
                                <textarea rows="5" class="form-control" class="text" placeholder="Message" name="comments" required data-validation-required-message="Please enter a message."></textarea>
                                <p class="help-block text-danger"></p>
                            </div>
                        </div>
                        <br>
                        <div id="success"></div>
                        <div class="row">
                            <div class="form-group col-xs-12">
                                <input type="submit" name="submit" value="Submit">
                            </div>
                        </div>
                    </form>
C.S.
  • 37
  • 5
  • 1
    Show us the PHP code, and make sure there's no other field with a `name="comments"` anywhere. Do a `print_r($_POST)` to check its contents, too. – ceejayoz Dec 10 '18 at 18:37
  • print_r doesnt seem to show it: Array ( [name] => Joe Bloggs [contactNo] => 0123445667 [email] => joe@gmail.com [submit] => Submit ) – C.S. Dec 10 '18 at 18:40
  • class="form-control" class="text" , this wouldn't cause the error, but not sure why you have class="" twice. Can you please post your whole form so we can see if there's other issues? Are you sure the textarea is in the form, and are you sure the form is being posted regularly with controller="' or is there JS sending the form data? – Nerdi.org Dec 10 '18 at 18:46
  • How do we know that is `Inside my form` or that you don't have another input with the same name after this one. In other words it's too little code to tell. – ArtisticPhoenix Dec 10 '18 at 18:46
  • Edited original post to include complete form. – C.S. Dec 10 '18 at 18:53

1 Answers1

1

Without having knowledge of you HTML form we can only make assumptions. I am quite sure your textarea is not part of the form aka not a descendant of the form node or it is styled with display: none utilizing CSS.

Bonscho
  • 133
  • 7