Page 1 of 1

PHP code in HTM not being executed?

Posted: Fri Oct 30, 2009 11:58 am
by Bob Kellock
I'm a complete novice to PHP so please excuse what is probably a very simple question.

echo("Fred");
works correctly in a .PHP file but not in an HTM, e.g.
My name is <?php echo(" Fred "); ?> Bloggs
only displays My name is Bloggs.

According to http://php.about.com/od/advancedphp/p/html_php.htm it says I need to add
AddType application/x-httpd-php .html
Or
AddType application/x-httpd-php .htm
to my .htaccess file.

If I do that and then open the HTML page the browser (Opera) comes up with a pop-up to download the html file.

What should I be doing?

Bob

Re: PHP code in HTM not being executed?

Posted: Fri Oct 30, 2009 1:35 pm
by akuji36
Hello

In order for php engine to recognize and process embedded php in html

form the entire file must be saved in php format ex

example.php

in example php file

you may write your html form

and include php.

thanks

Rod

Re: PHP code in HTM not being executed?

Posted: Fri Oct 30, 2009 2:13 pm
by Bob Kellock
Thanks, Rod.

I'd tried that but it simply puts up the message "No input file specified".

What sort of input file is wanted?

Bob

Re: PHP code in HTM not being executed?

Posted: Fri Oct 30, 2009 2:51 pm
by akuji36
Here's an example of php embedded in html form.


Note in this case all code is on one page
(sometimes the user is directed to another page which processes all the php code).

http://www.ntchosting.com/php/php-in-html.html

thanks

Rod