HighDots Forums  

How to Include PHP script in shtml file ???

JavaScript discussion (multi-lingual) JavaScript discussion (alt.comp.lang.javascript)


Discuss How to Include PHP script in shtml file ??? in the JavaScript discussion (multi-lingual) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
EnjoyNews
 
Posts: n/a

Default How to Include PHP script in shtml file ??? - 10-27-2005 , 08:38 AM






I have a php site I have an include line called "include 'Cookie.php';"

In this Cookie.php file I have these codes.

<?php
$conn = mysql_connect("$db", "$user", "$pass");
mysql_select_db("$db");

//--------------------------------------------------------------------------
-------------
//COOKIE
//--------------------------------------------------------------------------
-------------
$cookiename = 'TourCounter';
if( isset( $_COOKIE[$cookiename] ) ){$user_id = $_COOKIE[$cookiename];}
else {
mysql_query ("INSERT INTO CountUser (Dato) VALUES (now())");
$user_id = mysql_insert_id();
setcookie( $cookiename, $user_id, time()+315360000);
;}?>


This will set a cookie on the computer when people enters the site for the
first time, and update my database.
Now I can see how many new computers that see my site each day, and it works
fine.


BUT, now I have another site where all the pages are .shtml sites, and I
have not been using any php scripting at all, though it is uploadet on a
server where I can use php.

But now I can't include the file, cause if I write <!--#include
file="Cookie.php"--> it includes some php codes, but since the site is
called .shtml it offcause can't execute the php script.

But isn't there a way to do this anyway.
Maybe by some javascript that executes the Cookie.php fil or something. ??
The site has a lot a pages, and I would rather not rename them all to .php
and the shtml include to php include on all the pages.

I have a menu that is included on all the pages, so if it could be executed
in the menu file, I will count all hits, nomatter what site people enters
first.


Hope someone have a good idea.

best
Michael



Reply With Quote
  #2  
Old   
Jasen Betts
 
Posts: n/a

Default Re: How to Include PHP script in shtml file ??? - 11-02-2005 , 02:11 AM






On 2005-10-27, EnjoyNews <a@a.dk> wrote:

Quote:
I have a php site I have an include line called "include 'Cookie.php';"

But isn't there a way to do this anyway.
Maybe by some javascript that executes the Cookie.php fil or something. ??
The site has a lot a pages, and I would rather not rename them all to .php
and the shtml include to php include on all the pages.
Javascript can't communicate with PHP. by the time the browser sees the
javascript the PHP has finished executing.

Quote:
I have a menu that is included on all the pages, so if it could be executed
in the menu file, I will count all hits, nomatter what site people enters
first.
the easiest way is just to log the IP addresses of the computers, that'll
give a fair indication of how many different people visit on any day.

Otherwise maybe you could move all your SHTML down one directory deeper and
use a PHP errordoc, to serve them.

Another way would be to translate the SHTML to PHP. require() works like
include...

--

Bye.
Jasen


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.