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?
Printable View
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?
Does it have to be a .htm file?
er.. yeah :D thats the whole problem
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.
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?Quote:
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....
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...
you could try something like <!--#exec cgi="yourscript.php"-->
that does work if you only want to change the item being called, maybe you could dfo something like thisQuote:
Originally posted by deane034
img src = img_rand.php
[/B]
phppage.php
htmlpage.htmPHP Code:print 'document.write "'. $_REQUEST['cookiename'] . '"';
Code:<script language="javascript" src="phppage.php"></script>
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..
just found this, put it in the .htaccess file
it works for shtml files so maybe it could be changed for php files?Code:AddType text/x-server-parsed-html .html
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.Quote:
Originally posted by john tindell
maybe you could dfo something like this
phppage.php
htmlpage.htmPHP Code:print 'document.write "'. $_REQUEST['cookiename'] . '"';
Code:<script language="javascript" src="phppage.php"></script>
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,
thanksCode:
test.htm
<script language="javascript"
src="test.php"
</script>
trst.php
<?php
print("document.write(\"deane034\") ");
?>
ok didnt see hobo's post.. so does that mean there is no solution?
I already said that it wouldn't work...
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.Quote:
Originally posted by deane034
ok didnt see hobo's post.. so does that mean there is no solution?
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.
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:
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.Code:AddType application/x-httpd-php .htm
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.
Forgot to attache it :D
whats that?Quote:
Originally posted by Chroder
And if your on a Windows server, then your SOL.
Sh*t Outta Luck :D
lol :)
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 ...
Why does it display an index.php? :confused: