English 中文(简体)
安装自动功能取决于是否在现场访问
原标题:Embed Movie | want to set autoplay function dependent on whether they have visited site before

我有一部嵌入的电影,并试图建立一套能够让我看到用户以前到这里来的功能。 如果他们这样做,就会伪造汽车。

the followig code does not work <?php function autoplay(){ if ($REMOTE_ADDR == "") { $ip = "no ip"; echo "true"; } else{ $ip = getHostByAddr($REMOTE_ADDR); echo "false"; } } ?>

任何建议

问题回答

you could use a cookie that will be stored in the user s browser. session_start(); before everything else in the page, then setcookie( visited , yes ,$time+2592000); after that before loading the movie check if $_COOKIE[ visited ] == "yes"; and thats it. 2592000 are the seconds in a month. Paste this at the first line of your page:

<? session_start(); $loopif=($_COOKIE[ visited ]=="yes")?false:true;setcookie( visited , yes ,$time+2592000); ?>

然后,当用户事先访问时,当他打算这样做时,便会发生错失行为。

结束

建立了两个职能,并参照了嵌入的汽车部分的自动作用。

function ipfunction() {

    $ip=$_SERVER[ REMOTE_ADDR ];

    $queryone = "SELECT * from sessions where ip= $ip ";
    $result = mysql_query($queryone);
    if (mysql_num_rows($result) == 0) {
        mysql_query("insert into `sessions` (`id`, `session`, `ip`) VALUES (  ,  , $ip )");
    } else if (mysql_num_rows($result) != 0) {
        echo "";
    }
}

function autoplay() {

    $ip=$_SERVER[ REMOTE_ADDR ];

    $queryone = "SELECT * from sessions where ip= $ip ";
    $result = mysql_query($queryone);
    if (mysql_num_rows($result) == 0) {
        echo "true";
    } else if(mysql_num_rows($result) != 0) {
        echo "false";
    }
}




相关问题
why the session in iis automatically log out?

I used iis6, and when i called a function Directory.delete(), the all the session relate this website will be logged out. and i debugged the website, i found no exception. any one have ideas on this ? ...

Check session from a view in CodeIgniter

What is the best way to check session from a view in CodeIgniter, it shows no way in their user guide, otherwise I will have to make two views on everything, which is kinda weird...still a newbie to ...

Can I get the size of a Session object in bytes in c#?

Is it possible to get the size(in bytes) of a Session object after storing something such as a datatable inside it? I want to get the size of a particular Session object, such as Session["table1"], ...

提供严格分类的出席会议物体

提供严格分类的与会机会的最佳方式是什么? 我正计划转而选择矩阵,这正在促使汇编者抱怨我的幻觉方案拟订方法......

PHP Session is not destroying after user logout

I m trying to create an authentication mechanism for my PHP Application and I m having difficulty destroying the session. I ve tried unsetting the authentication token which was previously set within ...

热门标签