PDA

View Full Version : How to: call php in html page?


jacob
Sat 12th May '01, 7:17pm
I want to call this code:

<?
include("/home/site/public_html/test/counter.php");
?>

inside .html page "footer template" how I can do that?

Wayne Luke
Sat 12th May '01, 8:33pm
Rename it footer.php

jacob
Sat 12th May '01, 8:48pm
Oh No, I want to keep the original footer template but I want to add inside it counter.php, such that it show the visitors, how I can call php code?

c-prompt
Sun 13th May '01, 7:43am
<?
virtual("/test/counter.php");
?>

Try that.

Dysfunction
Sun 13th May '01, 11:33pm
Edit your php.ini and make .html read as PHP files also.

jacob
Mon 14th May '01, 3:38pm
virtual did not work!! I can not add my php.ini I'm on shared server.

I only want to add a php counter, how I can do that?

Dysfunction
Mon 14th May '01, 3:44pm
Right now, those are the only two options I have in mind! :(

tubedogg
Tue 15th May '01, 4:25am
By "footer template" do you mean vBulletin's footer template or a page named footer.html?

jacob
Tue 15th May '01, 10:21am
I mean vB footer template. it is simply, I want to add a 3rd party php counter in the vb footer template. this code

<?
include("/home/site/public_html/test/counter.php");
?>

and virtual does not execute the script in the page. if some can help to execute perl script <!--exec cgi= ... --> I will also appreciate it. anything to have a counter in the baord.

Mark4444
Sun 27th May '01, 11:57am
I have a php web counter that i want to call from a html page. The virtual command is a php command and doesn't excute in a html page any other suggestions?

i know you can call one php script form inside another one with the include command. Whats the html version of this?

Thanks in advance for any help :)

gregc
Mon 28th May '01, 3:46am
Hey, just rename it footer.php or whatever.php just like the other guy reccommended. You can do some echo() functions to write in the HTML tags, and you'll be fine.

Gregory C.

Mark4444
Mon 28th May '01, 10:07am
The counter IS already a php script. What i need is a way to call that script from the footer template which ONLY understands html.

s.molinari
Mon 28th May '01, 12:22pm
I don't mean to be a smart ass :), but why do you want a counter in the first place? I'm really interested in hearing your reasoning.

Here is my reasoning for not having one. Just my 2 cents. ;)

If your site is small or for that fact, big, there are the "views" column. This gives your visitors a good idea as to how much traffic your site/forums is/are getting. If your site is a more professional site then a counter is definitely not needed or wanted. Take a look at any professional site and you'll see no counter.... anywhere. Take the vB site for example.

There is also the members count. This too is a fairly good indicator of your sites usage.

If you really need the counter in the starting page, this is assuming of course that this is the only place you want to place a counter for visitors to see, I would do the following:

1. Call your script in the index.php script of vB using:
require("/home/site/public_html/test/counter.php");

2. Make sure the output of the script is HTML and save it to a variable and make sure it is public.

3. Now add the variable to the "forumhome" template, much like the $footer variable. You can place the variable almost anywhere you would like. You may have to tweak the html from your counter script to get things to look right though.

Again, you do only want the counter to be seen on the starting page, right? The footer is actually the wrong place to put your counter because it is in almost all the page templates. This would distort the number of "real" visits since you would be adding to the counter when almost every page in the forum is called.

There you have it. I am just learning this PHP stuff so I'm probably wrong but it's my guess. If I'm wrong or right please let me know.

Hope I could help.

Scott

gregc
Mon 28th May '01, 1:57pm
Just use echo() statements to print out your HTML tags! And just rename it with a .php extension................. I don't see why you can't do that. Oh yeah, and what the guy above this message said was right. If you have a counter on EVERY PAGE, then it'll look like you have more hits than you really have. Page views...

Gregory C.

Mark4444
Mon 28th May '01, 7:23pm
Your idea sounds like it should work Scott, thanks. I'm new to php myself and am just starting to learn it. And your right as far as the counter go's. I saw a java script counter on another board and wondered if i could get my php counter to work the same way. Also the counter has a ip lock feature which prevents it from advancing if the page is hit from the same ip in a set time frame which can be set to whatever the person running the counter wants.

Again thanks for the info going to see if i can get it to work now.

:D

c-prompt
Wed 30th May '01, 1:44pm
Virtual should work. Youre making sure your using the url addy, and not absolue path right?

Zajil
Mon 4th Jun '01, 7:58am
If you can change php.ini to deal with html files as php files, just paste this code in your html file ....

<OBJECT height=100% id=script type=text/x-scriptlet width=100%>
<PARAM NAME="Scrollbar" VALUE="0">
<PARAM NAME="URL" VALUE="yourScript.php">
</OBJECT>


:D