javascript - PHP form not submitting but not showing any errors -


i trying set simple coming-soon page contact form. have uploaded here (click contact now button).

now, when fill in information , click send, give me error message. can't see wrong , have error reporting set on (maybe on wrong place), here's php code:

<?php  ini_set('display_startup_errors',1); ini_set('display_errors',1); error_reporting(-1);   if (isset($_request['name'],$_request['email'])) {      $name = $_request['name'];     $email = $_request['email'];     $message = $_request['message'];      $to = 'editedforstackoverflow';      $subject = 'contact request website';     $headers = "from: ".$name." <".$email."> \r\n";      $send_email = mail($to,$subject,$message,$headers);      echo ($send_email) ? 'success' : 'error';  }  ?> 

and here js part:

    $('#ajax-contact').on('submit', function() {      // add text 'loading...' right after clicking on submit button.      $('.output_message').text('loading...');      var form = $(this);     $.ajax({         url: form.attr('action'),         method: form.attr('method'),         data: form.serialize(),         success: function(result) {             if (result == 'success') {                 $('.output_message').text('nachricht erfolgreich geschickt!');             } else {                 $('.output_message').text('da ist leider ein fehler unterlaufen!');             }         }     });      // prevents default submission of form after clicking on submit button.      return false; }); 

i can't see error made, appreciated!

looking @ form in site, seems <input> tags missing name attribute on name , email fields:

they need have name="name" , name="email" .serialize() values , bring them request. in turn in php, they'll inside $_request

here's demo on mean on missing name="". i've explicitly omit field 3 can see.

http://codepad.viper-7.com/rttpuq

so fix is. add name="name" , name="email" on <input> tags.

actual note in manual:

note: "successful controls" serialized string. no submit button value serialized since form not submitted using button. form element's value included in serialized string, element must have name attribute.


Comments