Thursday 15 May 2014

php - Issue with one page site contact form -


I have a page portfolio with contact form, I'm trying to get rid of this but did not succeed is. I'm not a PHP expert, so I try to explain as much as I can. Basically I have a contact template file (if possible) in my portfolio with the word press that I have used before but whatever I want to do. My main point is that when I preview my site in the browser, it shows the PHP code that is on the form.

  & lt ;? Php if ($ _SERVER ['REQUEST_METHOD'] == "POST") {// Check the field for error (empty ($ _ POST ["txtName"])) {$ errors ["txtName"] = "Please enter name. "; } If (empty ($ _ POST ["txtPhone"])) {$ errors ["txtPhone"] = "Please enter your phone number."; } If (empty ($ _ POST ["txtEmail"])) {$ errors ["txtEmail"] = "Please enter your email address."; } Else {if (! Eregi ('^ [[: alnum:]] [a-z0- 9_ \. \ -] * @ [a-z0- 9 \. \ -] + \. [Az] {2 {$ Errors ["txtEmail"] = "Please provide a valid email address.";}} If (counting ($ errors) & Lt; 1) {$ to = "test-email@gmail.com"; $ theme = 'BW Design Contacts'; $ Headers = "From:" $ _POST ["txtEmail"] "\ r \ n"; $ Header. = "Mime-version: 1.0 \ r \ n"; $ header. = "Content-type: text / html; charset = UTF-8 \ r \ n"; $ message = '& lt; html & gt; & Lt; body style = "font-family: aerial, helvicika, non-serif, font-size: 12px;" & Gt; '$ $ message.' '& Lt; p & gt; & lt; strong & gt; name: & lt; / strong & gt;' $ _POST ["txtName"] '& lt; br / & gt; ; & Lt; strong & gt; Phone: & lt; / strong & gt; '$ _POST ["Textphone"]' & lt; br / & gt; & lt; strong & gt; Email: & lt; / strong & 
'$ _POST ["txtEmail"] "
Strong & gt; Message: & lt; / strong & gt; & lt; br / & gt;' $ ' TxtTomment "] '& lt; / p & gt; & lt; / body & gt; & Lt; / Html & gt; '; If (! Mail ($ $, $ theme, $ message, $ header)) {$ errors ["send"] = "There was a problem sending your message, please try again."; }} & Lt; Div id = "contact form" & gt; & Lt ;? Php if (count ($ errors)> 0) {echo & lt; Ul style = "color: red; padding: 0 18px 22px;" & Gt; '; Liq . $ Error "& lt; / li & gt;"; Echo "& lt; / ul & gt;"; }? & Gt; & Lt ;? Php if ($ _SERVER ['REQUEST_METHOD'] == "Post" & amp; Count ($ errors) & lt; 1) {? & Gt; & Lt; P class = "success-message" & gt; & Lt ;? Php _e ('Thank you Your Message Has Been Sent'.); ? & Gt; & Lt; / P & gt; & Lt ;? Php} and {? & Gt; & Lt; Form id = "contact1" method = "post" action = "# message" class = "contact form" & gt; & Lt; P & gt; & Lt; Label = "txtName" & gt; Name & lt; / Label & gt; & Lt; Input type = "text" id = "txtName" name = "txtName" class = "field" size = "40" value = "& lt ;? Php $ _POST ['txtName']? & Gt; / & gt; Lt; / p & gt; & lt; p & gt; Label = "txtPhone" & gt; Phone & lt; / label & gt; & lt; input type = "text" id = "txtPhone" name = "TxtPhone" class = "field" size = "40" value = "& lt ;? Php echo $ _POST ['txtPhone']? & Gt; "/ & gt; & lt; / p> & lt; p & gt; Label =" txtEmail "> Email & lt; / Labels & gt; & lt; input type =" Text "id =" txtEmail "name =" txtEmail "class =" field "size =" 40 "value =" & lt ;? Php echo $ _POST ['txtEmail']? & Gt; "/ />


Label =" txtNomment "> Message