Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running PHP from an html file 1

Status
Not open for further replies.

rossmcl

Programmer
Apr 18, 2000
128
Is it possible (and it will have to be easier as I am brand new to PHP and HTML) to run a PHP script from within an html page?

I have got my php script that I want to run when someone visits my html page? Is it possible to make it run as soon as the page loads?

If so, how?!?

Would very much appreciate if you could help me on this.

RM


 
1. Make your html file how you want it
2. Insert your php code in between &quot;<?php&quot; and &quot;?>&quot;
3. Save the file as filename.php
4. Upload to your server (Providing it supports php)

Everytime anyone calls the page the php will be executed.

Check for examples and the manuel
 
Actually what Westbury suggests will only work if you have apache setup to parse .html or .htm or all files for php. From what I understand you need a line something like this in your .htaccess or httpd.conf file:

Code:
AddType application/x-httpd-php .html

I'm no expert on apache though, so it might be an idea to ask about this on the apache forum.

If, like me, you can't modify httpd.conf or use .htaccess on your server you can work around this by putting your .php file in an in line frame, using the html tag <iframe>. Checkout w3c for details on that.



----------------------------------------------------------------------------
The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.
 
...or you can totally forget tweaking apache and re-read Westbury's point #3

[bigsmile]

And for clarification: Is it possible to make it run as soon as the page loads?

PHP code does not run as soon as the page loads. It runs before the page loads on the client. The user will be witness to the PHP aftermath.


- - picklefish - -
Why is everyone in this forum responding to me as picklefish?
 
ok so i misread #3 my mistake.

Thing is i had a situation where i HAD to save as .html, because my client had a terrible jumbled mess of zillions of pages and framesets pointing back to index.html, and changing it to index.php was not an option.

Just wanted to share my solutions in case anyone had the same problem :)

----------------------------------------------------------------------------
The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.
 
Yes, MK - you post was helpful but lets not push newbies into the fire too fast.

I've been considering doing that AddType tweak to my sites just so that folks believe that they are looking at good old static HTML.

- - picklefish - -
Why is everyone in this forum responding to me as picklefish?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top