js+php implement static page real-time call User login state method, static page user Login
In this paper, we describe the method of js+php implementing static page real-time call user login state. Share to everyone for your reference. The specific analysis is as follows:
In the program development, often the page into a static form of HTML, which can alleviate the server load, but there is also a problem is when the registered user login, in the HTML page to display the login success or need to login prompt, so we have to think of other ways to achieve, the following we are using js+ PHP to the instance, of course, Ajax can also be implemented, the code is as follows:
Copy the Code code as follows:
Static page real-time call user login and Exit login program (Web effect call PHP code)
loginajax.php file, because loginajax.php is called by the JS form of output, so the code inside the file due to the JS output can be displayed correctly, the code is as follows:
Copy the Code code as follows: <?php
$id = isset ($_get[' fid ")? $_get[' FID ']:0;
if (!isset ($_cookie[' VVG ')) {
?>
document.write (' User name:');
document.write ('');
<?php
}
Else
{
Echo ' document.write (' ['. $_cookie[' realname '], ' speak out ');
}
?>
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/937092.html www.bkjia.com true http://www.bkjia.com/PHPjc/937092.html techarticle js+php implement static page real-time call the user login state method, static page user Login This paper describes the js+php implementation of static page real-time call User Login state method. Share ...