Jump to content


Photo

make php work in html files


  • Please log in to reply
13 replies to this topic

#1 neugi

neugi
  • Members
  • PipPipPip
  • Advanced Member
  • 63 posts

Posted 30 June 2006 - 07:03 AM

Hi,

what do i have to change that php code works in html also?

best

#2 fert

fert
  • Members
  • PipPipPip
  • Advanced Member
  • 1,114 posts

Posted 30 June 2006 - 07:12 AM

use change the file extension to .php and then you can use php and html 

Si hoc legere scis nimium eruditionis habes
Gentoo Linux 2007.0 Firefox 2

#3 Unseeeen

Unseeeen
  • Members
  • PipPip
  • Member
  • 18 posts

Posted 30 June 2006 - 07:31 AM

read up on mod_rewrite in .htaccess files.

#4 php_joe

php_joe
  • Members
  • PipPipPip
  • Advanced Member
  • 175 posts

Posted 30 June 2006 - 07:42 AM

use change the file extension to .php and then you can use php and html 


I think he means without changing the extension (for example: so it runs on a website that is not php enabled, such as geocities).

I've heard that you can do this with JavaScript. They always say to use this:

<script language="javascript" src="http://whatever/php_script.php."> </script>

But that's never worked for me. I've also seen this suggested:

<img src="php_script.php" />

But I only get a red X when I tried it.

Feel free to try them if you like.

I did find a JavaScript snippit that did return the php output, but only the output from the php file and nothing from the original html webpage (no code... nothing). Not only that, but when I tried to refresh the page (after deleting the JavaScript) it wouldn't change. The php output always showed up even with no code in the html file and the php file renamed!

I'm also interested in a way to display a php output on an html page (aside from using an iframe) on a server such as geocities that doesn't support php.

Joe
[url=http://darkswordsguide.com][/url]

#5 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 30 June 2006 - 07:45 AM

just change the file exstention as advised ok.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#6 neugi

neugi
  • Members
  • PipPipPip
  • Advanced Member
  • 63 posts

Posted 30 June 2006 - 11:43 AM

i want that the extension html is prasing the php code ;)

i've got my own server where i can change everything, also the php ini. i only need to know which of them i've to change.

best

#7 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 30 June 2006 - 12:13 PM

If you want your PHP code to be parsed in a HTML file you need to edit the servers config file. Such as for Apache you need to find a file called httpd.conf. Look for a a line like this:
AddType application/x-httpd-php .php
Now add a space after .php and add .html to the end. Save the httpd.conf file restart Apache. You should now be able to parse PHP code in your html files.

#8 neugi

neugi
  • Members
  • PipPipPip
  • Advanced Member
  • 63 posts

Posted 30 June 2006 - 12:28 PM

i've searched for this file, but haven't found what i'm looking for.

this is in the file:

# This is here for backwards compatability reasons and to support
#  installing 3rd party modules directly via apxs2, rather than
#  through the /etc/apache2/mods-{available,enabled} mechanism.
#
#LoadModule mod_placeholder /usr/lib/apache2/modules/mod_placeholder.so


i've also searched for files containg a string like the one you told me, but nothing there

best

#9 xyn

xyn
  • Members
  • PipPipPip
  • Advanced Member
  • 779 posts
  • LocationNorthampton

Posted 30 June 2006 - 12:50 PM

I discovered something about this the other day.. I'm not sure if it works but try this:

<!DOCTYPE PHP PUBLIC "-//W3C//DTD php Transitional//EN">

I'm not sure if that is 100% correct, otherwise just use the .php extension as advised.

#10 Koobi

Koobi
  • Staff Alumni
  • Advanced Member
  • 419 posts
  • LocationColombo, Sri Lanka | South Asia

Posted 30 June 2006 - 01:32 PM

what version of Apache are you on?
I believe Apache 2 uses apache2.conf instead of httpd.conf it's generally located in /etc/apache2/apache2.conf
generally, all configuration files are located in the /etc/ folder

#11 neugi

neugi
  • Members
  • PipPipPip
  • Advanced Member
  • 63 posts

Posted 30 June 2006 - 01:46 PM

Hi,

version ist: Apache Version 2.0.54

best

#12 Koobi

Koobi
  • Staff Alumni
  • Advanced Member
  • 419 posts
  • LocationColombo, Sri Lanka | South Asia

Posted 30 June 2006 - 02:32 PM

Hi,

version ist: Apache Version 2.0.54

best


ok thanks.
did it occur to you that you should have perhaps tried looking for apache2.conf? :)

#13 neugi

neugi
  • Members
  • PipPipPip
  • Advanced Member
  • 63 posts

Posted 30 June 2006 - 02:58 PM

i'm new to linux ;)

now it works i've also to remove the # in from of it ;)

best

#14 Koobi

Koobi
  • Staff Alumni
  • Advanced Member
  • 419 posts
  • LocationColombo, Sri Lanka | South Asia

Posted 30 June 2006 - 04:58 PM

Glad you sorted it out :)

I will move this topic to the Apache Server section because people are more likely to search for something like this in that forum.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users