php - Contact form doesnt work -


I have written the code for the contact form and I do not know why it does not work. Everything has been set up with the form but I did not receive the email. I did not get any errors or anything. It is html code :

   gt; & Lt; / Span & gt; & Lt; / Div & gt; & Lt; div class = "form-field call-sm-6" & gt; & Lt; Label = "email" & gt; Email & lt; / Labels & gt; & Lt; Span & gt; & Lt; Input type = "email" name = "email" id = "email" /> gt; & Lt; / Span & gt; & Lt; / Div & gt; & Lt; Div class = "form-field call-sm-6" & gt; & Lt; Label & gt; * What is 2 + 2? (Anti Spam) & lt; / Labels & gt; & Lt; Span & gt; & Lt; Input name = "human" placeholder = "write here" & gt; & Lt; / Span & gt; & Lt; / Div & gt; & Lt; Div class = "form-field col-sm-12" & gt; & Lt; Label = "message" & gt; Message & lt; / Label & gt; & Lt; Span & gt; & Lt; Textarea name = "message" id = "message" & gt; & Lt; / Textarea & gt; & Lt; / Span & gt; & Lt; / Div & gt; & Lt; / Fieldset & gt; & Lt; div class = "form-click center call-sm-12" & gt; & Lt; Span & gt; & Lt; Input type = "submit" name = "submit" value = "send it" id = "submit" gt; & Lt; / Span & gt; & Lt; / Div & gt; & Lt; div id = "alert" class = "col-sm-12" & gt; & Lt; / Div & gt; & Lt; / Form & gt;   

This is the php code :

  & lt; Php $ name = $ _POST ['name']; $ Email = $ _POST ['email']; $ Message = $ _POST ['message']; $ From = 'to: tangledmo'; $ To = 'kreso.galic8@gmail.com'; $ Theme = 'hello'; $ Human = $ _POST ['human']; $ Body = "From: $ name \ nEmail: $ email \ nMsg: \ n $ message"; If ($ _POST ['submit']) {if ($ name! = '' & '' '' $ '!' = '') {If ($ human == '4') {if (mail ($ to $, $ Subject, $ body, $)) {echo '& lt; P & gt; Your message has been sent! & Lt; / P & gt; '; } Else {echo & lt; P & gt; Something went wrong, go back and try again! & Lt; / P & gt; '; }} And if ($ _POST ['submit'] and $ human! = '4') {echo & lt; P & gt; You answered incorrectly to the anti-spam question! & Lt; / P & gt; '; }} Else {echo & lt; P & gt; You need to fill up all the required fields !! & Lt; / P & gt; '; }}? & Gt;    

It looks like if ($ _POST ['submit']) { is not working.

You should use the empty or isset :

  if (! Empty ($ _POST ['submit ']) {{Code>  

or

  if (isset ($ _ POST [' submit '])) {  < P> Be careful, if the user enters an input field instead of clicking on the submit button, the submit value will not be sent.  

You can use a hidden field instead:

  & lt; Input type = "hidden" name = "OK" value = "1" />    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -