Saturday, 15 May 2010

Portion of my php is displaying in the browser -


I am trying to add a php to send a website when the user clicks on a submit button. For some reason, a part of my php is appearing in the browser and I do not know why I have seen the information and tried to check my quotes and things like that, but I do not know that its one What would be the reason for displaying part as text.

screenshot of PHP

  & lt; Php $ action = $ _ request ['action']; If ($ action == "") / * contact form * / {? & Gt; & Lt; Form id = "contact-form" action = "" method = "post" encrypt = "multipart / form-data" & gt; & Lt; Div class = "row" & gt; & Lt; Label = "name" & gt; Your name: & lt; / Label & gt; & Lt; Br / & gt; & Lt; Input id = "name" class = "input" name = "name" type = "text" value = "" size = "30" /> gt; & Lt; Br / & gt; & Lt; / Div & gt; & Lt; Div class = "row" & gt; & Lt; Label = "email" & gt; Your Email: & lt; / Label & gt; & Lt; Br / & gt; & Lt; Input id = "email" class = "input" name = "email" type = "text" value = "" size = "30" /> gt; & Lt; Br / & gt; & Lt; / Div & gt; & Lt; Div class = "row" & gt; & Lt; Label = "message" & gt; Your message: & lt; / Label & gt; & Lt; Br / & gt; & Lt; Textarea id = "message" class = "input" name = "message" rows = "7" cols = "30" & gt; & Lt; / Textarea & gt; & Lt; Br / & gt; & Lt; / Div & gt; & Lt; Input id = "submit-button" type = "submit" value = "send email" /> & Lt; / Form & gt; & Lt ;? Php} Other / * Send submitted data * / {$ name = $ _ request ['name']; $ Email = $ _ request ['email']; $ Message = $ _ request ['message']; If (($ name == "") || ($ email == "") || ($ message == "")) {echo "All fields are required, please fill the form again."; } And {$ from = "to: $ name & lt; $ email & gt; \ r \ n return-path: $ email"; $ Theme = "Message sent using your contact form"; Mail ("email@gmail.com", $ theme, $ message, $); Echo "Email Sent!"; }}? & Gt;  

Why is this being understood ...

Meditation Given how the code part is only a bit in your code after and is ? Specifically & gt; .

When you open a PHP file in your browser, most PHP codes will not be shown by the browser except by a large, invalid HTML tag and the visual source and document inspector tool, without processing it on the server. . However, since your code has & gt; , it marks the end of the "invalid HTML tag" and anything after the page appears.

To fix this, use a server! PHP has a built-in form of 5.4, so if you installed it on your machine, you can open a command line in your PHP root folder:

  php -S localhost: 8000  

Then open a browser and go to http: // localhost: 8000 / yourfile.php and it will run. Nifty!


No comments:

Post a Comment