473,383 Members | 1,818 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Embed PHP script in HTML page...

Hi there,

The first page of my Internet website must be INDEX.HTM.
But, if I want to embed some PHP code in this page, I must rename it to
INDEX.PHP.
Easy, but not simple, because INDEX.PHP will not load as the default
startup-page of my website.

So, my question is:
How can I embed some PHP code within a normal HTML page (without using the
..PHP extension)?

Thank you in advance.

Regards,
Stefan.
Jul 17 '05 #1
8 13128

"Stefan van Roosmalen" <ro******@planet.nl> wrote in message
news:ci**********@reader11.wxs.nl...
Hi there,

The first page of my Internet website must be INDEX.HTM.
Not if you are using the Apache web server. In httpd.conf there is an entry
called DirectoryIndex which lists out the possible filenames which are
supposed to be the default index page withinn each directory. These file
names are scanned left to right, and the first one that's found is
processed. In the following example:

DirectoryIndex index.html index.html.var index.htm index.php

"index.html" comes before "index.htm" which comes before "index.php". You
can put whatever files names you like in there. Some people like
"default.html" instead of "index.html", so you see you are not stuck to a
single file name.

If you are not using Apache then read the documentation for a similar
DirectoryIndex drective.

--
Tony Marston

http://www.tonymarston.net
But, if I want to embed some PHP code in this page, I must rename it to
INDEX.PHP.
Easy, but not simple, because INDEX.PHP will not load as the default
startup-page of my website.

So, my question is:
How can I embed some PHP code within a normal HTML page (without using the
.PHP extension)?

Thank you in advance.

Regards,
Stefan.

Jul 17 '05 #2
Tony Marston wrote:
"Stefan van Roosmalen" <ro******@planet.nl> wrote in message
news:ci**********@reader11.wxs.nl...
Hi there,

The first page of my Internet website must be INDEX.HTM.


Not if you are using the Apache web server. In httpd.conf there is an entry
called DirectoryIndex which lists out the possible filenames which are
supposed to be the default index page withinn each directory. These file
names are scanned left to right, and the first one that's found is
processed. In the following example:

DirectoryIndex index.html index.html.var index.htm index.php

If you are not using Apache then read the documentation for a similar
DirectoryIndex drective.


IINM, you can also use the DirectoryIndex directive for a per-dir in
..htaccess files as well.

--
Justin Koivisto - sp**@koivi.com
http://www.koivi.com
Jul 17 '05 #3
Stefan van Roosmalen <ro******@planet.nl> wrote or quoted:
The first page of my Internet website must be INDEX.HTM.
But, if I want to embed some PHP code in this page, I must rename it to
INDEX.PHP.
Easy, but not simple, because INDEX.PHP will not load as the default
startup-page of my website.


Apache is not set up to handle PHP index files in its config file?

Can you fix that?
--
__________
|im |yler http://timtyler.org/ ti*@tt1lock.org Remove lock to reply.
Jul 17 '05 #4
In article <ci**********@reader11.wxs.nl>,
"Stefan van Roosmalen" <ro******@planet.nl> wrote:
Hi there,

The first page of my Internet website must be INDEX.HTM.
But, if I want to embed some PHP code in this page, I must rename it to
INDEX.PHP.
Easy, but not simple, because INDEX.PHP will not load as the default
startup-page of my website.

So, my question is:
How can I embed some PHP code within a normal HTML page (without using the
.PHP extension)?

Thank you in advance.

Regards,
Stefan.


This is a function of your ISP's web server (or how you've configured
your web server on the system you're testing this on). Apache only uses
the mod_php module when you name a page with the .php extension.

There's no way to have a "INDEX.HTM" run a php script on Apache, sorry.
So, you'll have to live with this restriction.

--
DeeDee, don't press that button! DeeDee! NO! Dee...

Jul 17 '05 #5
Stefan van Roosmalen wrote:
The first page of my Internet website must be INDEX.HTM.
Why?
But, if I want to embed some PHP code in this page, I must rename it to
INDEX.PHP.
Decent servers can have files with '.htm' filename
extensions parsed by PHP; any file can be, with any or no
filename extension.
Easy, but not simple, because INDEX.PHP will not load as the default
startup-page of my website.
The default file can be changed on decent servers.
So, my question is:
How can I embed some PHP code within a normal HTML page (without using the
.PHP extension)?


Configure the server to have files with a '.htm' (or
'.html', or whatever) filename extension parsed by PHP.

I'd do it differently. I'd maintain common, logical
filename extensions: files to be parsed by PHP have the
extension '.php'; HTML files have '.html'; plain text,
'.txt'; and so on. I'd also support URI persistency by
publishing URIs without suffixes, e.g.,
http://domain.example/foo , instead of
http://domain.example/foo.php .

--
Jock
Jul 17 '05 #6
"Michael wrote:
There's no way to have a "INDEX.HTM" run a php script on Apache, sorry.
So, you'll have to live with this restriction.


BS:

AddType application/x-httpd-php .php .htm
--

Daniel Tryba

Jul 17 '05 #7
Stefan van Roosmalen wrote:
Hi there,


Why do you keep on multi-posting? Cross-post next time!

http://www.usenet.com/articles/cross_posting.htm
JW

Jul 17 '05 #8
Stefan van Roosmalen wrote:

The first page of my Internet website must be INDEX.HTM.
But, if I want to embed some PHP code in this page, I must rename it to
INDEX.PHP.
Easy, but not simple, because INDEX.PHP will not load as the default
startup-page of my website.


Are you assuming the first page has to be index.htm? Because if you tried an
index.php, but didn't rename the index.htm, in most setups, the HTM would take
precedence over the PHP. If this is the case, make an index.php and rename
index.htm to something else like index-backup.htm. Also, make sure there are no
index.html, index.cgi, etc.

If that still doesn't work you can make an .htaccess file if you're using
Apache. You can go 2 routes:
Override your server's default directory index:

DirectoryIndex index.php
Or, force Apache to treat index.htm as a PHP file:

<Files index.htm>
ForceType application/x-httpd-php
</Files>

Just add whatever lines you want to the existing .htaccess, or, if one doesn't
already exist, create a file called .htaccess with whatever lines you want and
put it in your server's web root. Be careful you don't overwrite existing
..htaccess files and be aware that whatever you specify will be inherited by
child directories (i.e. if you make index.php the default directory index at
http://www.yourdomain.com/, it'll be the default at
http://www.yourdomain.com/subdirectory/).

If these options don't work, please tell us what server you're using...

Shawn
--
Shawn Wilson
sh***@glassgiant.com
http://www.glassgiant.com
Jul 17 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Csaba2000 | last post by:
I want to be able to embed a single quote into an INPUT element within a dynamically generated IFRAME. The example below shows how the IFRAME is generated. Challenge: I'd like the alert box to...
2
by: Cris Curtis | last post by:
When I use an embed tag that uses a dynamic aspx page, the dynamic aspx page appears to get called 2 times instead. Below is code that adds an embed tag to a placeholder control that will use...
5
by: girishmat | last post by:
how to embed or open microsoft word file in a page using php script
3
by: abrtlt | last post by:
I would like to have a web page in which, when the user clicks on any of several specific elements, a specific audio file is played, without reloading the page. The specific audio file name is...
5
by: elbin | last post by:
Hello, first to say that I am a total beginner in Javascript but I know some programming (python in particular) and am able to understand methods/parameters and so on. Here's my problem: I am...
0
by: =?Utf-8?B?TWFyazEyMw==?= | last post by:
I have two pieces of VB.NET code below: a) Sends an email b) Returns a programmatically created jpeg image to a webpage. How can I embed the programmatically created jpeg into an HTML...
1
by: ShahzadMahmood | last post by:
I want to embed the following code in javascript function javascript function is written just after the object code, I want to replace the popup window code with this object code while the file name...
2
dream party
by: dream party | last post by:
Inserting a Flash (SWF, FLV) file into HTML web page is already an old and familiar thing to all of us. It is a rather non-flexible thing that just to edit some options in the template. However, I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.