Home >Backend Development >PHP Tutorial >js php method to realize real-time calling of user login status in static page_PHP tutorial

js php method to realize real-time calling of user login status in static page_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 09:59:351146browse

JS PHP method to realize real-time calling of user login status in static page

This article mainly introduces the method of realizing real-time calling of user login status in static page in JS PHP. Use js to call the php page to realize the real-time calling function of the user's login status. Friends who need it can refer to it

The example in this article describes the method of using js php to realize real-time calling of user login status in static pages. Share it with everyone for your reference. The specific analysis is as follows:

In program development, the page is often made into a static form of HTML, which can reduce the server load. However, there is also a problem that when a registered user logs in, a prompt that the login is successful or requires login must be displayed on the HTML page. In this way, we must think of other ways to achieve it. Below we will use js php to implement it. Of course, ajax can also be implemented. The code is as follows:

The code is as follows:





The static page calls the user login and logout procedures in real time (the web page special effects call the php code)






loginajax.php file, because loginajax.php is called and output in js format, so the code in this file can be displayed correctly because it is output in js format. The code is as follows:

The code is as follows:

$id = isset( $_get['fid'] )?$_get['fid']:0;
if( !isset($_cookie['vvg']) ){
?>
document.write('Username:');
document.write('');
}
else
{
echo 'document.write('['.$_cookie['realname'],']SpeakExit');';
}
?>

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/975896.htmlTechArticleJS PHP realizes the method of real-time calling of user login status in static pages. This article mainly introduces the method of realizing real-time static pages in JS PHP. The method of calling the user's login status is to use it in a static page...
Statement:
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