如何在shtml文件中包含PHP脚本??? [英] How to Include PHP script in shtml file ???
问题描述
我有一个php网站,我有一个名为include'Cookie.php'的包含行;'"
在这个Cookie.php文件中,我有这些代码。
<?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);
;}?>
当人们进入时,这将在计算机上设置一个cookie第一次使用
的网站,并更新我的数据库。
现在我可以看到每天有多少新电脑看到我的网站,并且它可以工作
罚款。
但是,现在我有另一个网站,其中所有页面都是.shtml网站,而且我还没有使用任何PHP脚本,尽管它是一个
服务器的uploadet,我可以使用php。
但现在我不能包含该文件,因为如果我写<! - #include
file =" Cookie.php" - >它包含一些PHP代码,但由于该网站是名为.shtml的
,因此无法执行php脚本。
但是不是无论如何,有一种方法可以做到这一点。
也许通过一些执行Cookie.php文件的javascript或其他东西。 ??
该网站有很多页面,我宁愿不将它们全部重命名为.php
和shtml include到php包含在所有页面上。
我有一个包含在所有页面上的菜单,所以如果它可以在菜单文件中执行
,我会计算所有的点击数,不管是什么网站的人首先输入
。
希望有人有个好主意。
最好
迈克尔
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
推荐答案
conn = mysql_connect("
conn = mysql_connect("
db","
db", "
>
user","
user", "
这篇关于如何在shtml文件中包含PHP脚本???的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!