|
-
Sep 1st, 2003, 07:01 AM
#1
Thread Starter
Hyperactive Member
PHP in .htm files
hi guys, is there a way to call php functions wihtin a .htm file, for example
let's say i have a script which checks for a cookie for user preferences. and a seperate .htm file which uses these information, how is it achieved?
-
Sep 1st, 2003, 09:39 AM
#2
<?="Moderator"?>
Does it have to be a .htm file?
-
Sep 1st, 2003, 11:14 AM
#3
Thread Starter
Hyperactive Member
er.. yeah thats the whole problem
-
Sep 1st, 2003, 11:33 AM
#4
Stuck in the 80s
No, you cannot have PHP in an .htm file.
A .php file is parsed on the server, and all output is sent to the browser.
A .htm file is sent to the browser as output without any parsing done. Any javascript, etc is done on the client itself.
-
Sep 1st, 2003, 11:36 AM
#5
Thread Starter
Hyperactive Member
some sort of a redirection maybe.. are u 100% positive.. isnt it possible to call the external php file and ge the output.. and like..
img src = img_rand.php
and img_rand would retrive the image name.. i have seen this done somewhere....
-
Sep 1st, 2003, 11:52 AM
#6
Stuck in the 80s
Originally posted by deane034
some sort of a redirection maybe.. are u 100% positive.. isnt it possible to call the external php file and ge the output.. and like..
img src = img_rand.php
and img_rand would retrive the image name.. i have seen this done somewhere....
If you can do that, why can't you just use a .php file? What's your reason for needing a .htm file?
And I'm 100% positive that you need to have PHP parsed on the server, and .htm files are most likely just sent directly to the client as output without being parsed for PHP.
I'd be willing to bet...well, an empty wallet on it. Because I'm broke. But if I had money...
-
Sep 1st, 2003, 11:53 AM
#7
<?="Moderator"?>
you could try something like <!--#exec cgi="yourscript.php"-->
-
Sep 1st, 2003, 11:57 AM
#8
<?="Moderator"?>
Originally posted by deane034
img src = img_rand.php
[/B]
that does work if you only want to change the item being called, maybe you could dfo something like this
phppage.php
PHP Code:
print 'document.write "'. $_REQUEST['cookiename'] . '"';
htmlpage.htm
Code:
<script language="javascript" src="phppage.php"></script>
-
Sep 1st, 2003, 11:57 AM
#9
Thread Starter
Hyperactive Member
coz this ppl i am buildin the scripts.. hate PHP.. they want.. a .htm extention.. god knows why.. i have to give them reasons why it isnt possible..
-
Sep 1st, 2003, 12:02 PM
#10
<?="Moderator"?>
just found this, put it in the .htaccess file
Code:
AddType text/x-server-parsed-html .html
it works for shtml files so maybe it could be changed for php files?
-
Sep 1st, 2003, 01:32 PM
#11
Stuck in the 80s
Originally posted by john tindell
maybe you could dfo something like this
phppage.php
PHP Code:
print 'document.write "'. $_REQUEST['cookiename'] . '"';
htmlpage.htm
Code:
<script language="javascript" src="phppage.php"></script>
That wont work. The server will think it's a javascript file and send it to the client so that it can be parsed as so. It will not be parsed as PHP on the server.
-
Sep 1st, 2003, 02:00 PM
#12
Thread Starter
Hyperactive Member
hi thanks for the replies, i think what i saw was something similar to the java script method Jogn posted earlier.. i am real new to scripting.. so help out guys...
i tried the way jogn suggested. and i ddint somehow get the thing working. tyhis is the code i used,
Code:
test.htm
<script language="javascript"
src="test.php"
</script>
trst.php
<?php
print("document.write(\"deane034\") ");
?>
thanks
-
Sep 1st, 2003, 02:02 PM
#13
Thread Starter
Hyperactive Member
ok didnt see hobo's post.. so does that mean there is no solution?
-
Sep 1st, 2003, 02:02 PM
#14
Stuck in the 80s
I already said that it wouldn't work...
-
Sep 1st, 2003, 02:04 PM
#15
Stuck in the 80s
Originally posted by deane034
ok didnt see hobo's post.. so does that mean there is no solution?
Personally, I'd go talk to the people you're working for and slap the ignorance out of them. Explain to them what a great technology PHP is and that even using .htm files is outdated.
Ask them if they want to be stuck in the early 90s forever.
Otherwise, I believe you can manipulate cookies with javascript. I'm not sure about it, though, but I vaguely remember hearing about it.
-
Sep 1st, 2003, 02:19 PM
#16
Member
You can force the server (*nix server) to parse any file you want with .htaccess. Download the attatched file, extract the .htaccess file and upload it to the dirctory you want this forcing to take action in. The .htaccess file contains the following code, if you want to make it yourself:
Code:
AddType application/x-httpd-php .htm
Now the server see's the htaccess file and knows that you want it to recognize the .htm files as PHP and force parse it.
Though there's no point in trying this if you host doesn't even support PHP!
So just upload the .htaccess file and stick in your PHP. No need to put <script> or anything in.
And if your on a Windows server, then your SOL.
-
Sep 1st, 2003, 02:20 PM
#17
-
Sep 1st, 2003, 02:40 PM
#18
<?="Moderator"?>
Originally posted by Chroder
And if your on a Windows server, then your SOL.
whats that?
-
Sep 1st, 2003, 02:48 PM
#19
-
Sep 1st, 2003, 03:17 PM
#20
-
Sep 1st, 2003, 11:27 PM
#21
Thread Starter
Hyperactive Member
thanks ppl..
hey chroder is there way to set the .htaccess file so that it only parses only some given list of htm files... coz they now they only want theere home page index.htm to be in index.htm.. so that the browser will display ww.something.com instead of something.com/index.php ...
-
Sep 2nd, 2003, 10:07 AM
#22
Stuck in the 80s
Why does it display an index.php?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|