Home > Backend Development > PHP Tutorial > 论坛留言板是怎么实现非登录用户点击留言框弹出用户没有登录提示框的

论坛留言板是怎么实现非登录用户点击留言框弹出用户没有登录提示框的

WBOY
Release: 2016-06-13 10:24:51
Original
966 people have browsed it

论坛留言板是如何实现非登录用户点击留言框弹出用户没有登录提示框的
论坛留言板是如何实现非登录用户点击留言框弹出用户没有登录提示框的,请问是不是session配合Java实现的,具体是一个什么样的实现过程。

------解决方案--------------------
Demo:

PHP code
<?php /* Created on [2012-5-21] Author[Newton] */?>  <textarea name="message" rows="10" cols="50" onclick="checkUser()" wrap="off">  Give message please.  </textarea>  <script language="JavaScript" type="text/javascript">//Ajaxvar xmlHttp;    function createXMLHttpRequest() {        if(window.XMLHttpRequest) {            xmlHttp = new XMLHttpRequest();        } else if (window.ActiveXObject) {            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");        }    }    function checkUser(){        createXMLHttpRequest();        url = "action.php?check=ok&ran="+Math.random();        method = "GET";        xmlHttp.open(method,url,true);        xmlHttp.onreadystatechange = show;        xmlHttp.send(null);    }    function show(){        if (xmlHttp.readyState == 4){            if (xmlHttp.status == 200){                var text = xmlHttp.responseText;                alert(text);exit;                //document.getElementById("s2").innerHTML = text;    //可将返回信息放入id为s2的div中            }else {                alert("response error code:"+xmlHttp.status);            }        }    }  </script>#action.phpif(isset($_GET['check'])){    #mysql执行语句,检测用户是否存在    echo "检验中……";}<br><font color="#e78608">------解决方案--------------------</font><br>
Copy after login
探讨

ajax来实现。onfocus触发ajax求请求php检查是否登录。
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template