PHP email form not posting name or phone number -


I can not know why my php name and phone number is not sending over email to email and message working properly Are there.

Here's my HTML:

  & lt; Form method = "POST" name = "contact_form" action = "php.php" & gt; & Lt; Label = 'fname' for & gt; Name: & lt; / Label & gt; & Lt; Input type = "text" name = "fname" & gt; & Lt; Label = 'email' for & gt; Email: & lt; / Label & gt; & Lt; Input type = "text" name = "email" & gt; & Lt; Label = 'phone' for & gt; Phone: & lt; / Label & gt; & Lt; Input type = "text" name = "phone" & gt; & Lt; Label = 'message' & gt; Message: & lt; / Label & gt; & Lt; Textarea name = "message" rows = 8 cols = 30> gt; & Lt ;? Php echo htmlentities ($ user_message)? & Gt; & Lt; / Textarea & gt; & Lt; Label & gt; & Lt; Img src = "/ captcha.php" & gt; & Lt; / Labels & gt; & Lt; Input type = "text" name = "code" value = "please enter code" & gt; & Lt; Br / & gt; & Lt; Input type = "submit" value = "submit" name = 'submit' class = "quotation button" & gt; & Lt; / Form & gt;  

Here's my PHP:

  session_start (); If (isset ($ _ POST ['submit'])) {$ error = ""; If (! ($ _ POST ['fname'])) {$ name = $ _POST ['fname']; } And {$ error. = "You did not type your name. 
"; } If (! ($ _ POST ['phone'])) {$ name = $ _POST ['phone']; } And {$ error. = "You did not enter your phone.
"; } If (! ($ _ POST ['email'])) {$ email = $ _POST ['email']; If (Preg_match ("/ ^ [a-z0-9] + (\. [_A-z0-9 -] +) * @ [a-z0-9 -] + (\ [A-z0- 9 The email address you entered is not valid. & Lt; br / & gt; & lt; br / & Gt; "; }} And {$ error. = "You did not type in e-mail address.
"; } If (! ($ _ POST ['message'])) {$ message = $ _POST ['message']; } And {$ error. = "You did not type in a message.
"; } If (($ _ POST ['code']) == $ _SESSION ['code']) {$ code = $ _POST ['code']; } And {$ error. = "The captcha code you entered does not match, please try again.
"; } If (empty ($ error)) {$ from = 'to:' $ Fname '& lt;' . $ Email '& gt;'; $ From = "mail@domain.com"; $ Theme = "new contact form message"; $ Content = $ fname "has sent you a message. \ N Email: $ email \ n Phone: $ phone \ n Message: \ n". $ Message; $ Success = header ('location:' '); Mail ($ $, $ theme, $ content, $); }}? & Gt;

Any help would be greatly appreciated. Thanks!

1) You have named the variable name for the first name $ name But in the email part of the code $ fname

  $ name = $ _POST ['fname'];  

should be

  $ fname = $ _POST ['fname'];  

2) You have named the variable name for the first name $ name (overwriting your initial assignment), but in the email part $ phone Use code

  $ name = $ _POST ['phone'];  

should be

  $ phone = $ _POST ['phone'];  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -