How jquery ajax implements static html page logon and exit

Source: Internet
Author: User
Tags echo date

For example, html code is very simple

<Div id = 'axaxlogin'> Here, the status information is displayed in html, because ajax will replace the content, to prevent loading delays, we can provide some logon instructions by default. </div>

The code is as follows: Copy code

<Script language = "javascript"> $ ('# ajaxlogin'). load ('ajaxlogin. php? Cityid = 1208 '); </script>

Ajaxlogin. php

This file is very simple to determine whether the user is logged on, as shown in figure

The code is as follows: Copy code


<? Php
If (isset ($ _ SESSION ['user']) {
?>
<Div id = "result">
<P> <strong> <? Php echo $ _ SESSION ['user'];?> </Strong> Congratulations! </P>
<P> This is the <span> <? Php echo $ _ SESSION ['login _ counts'];?> </Span> log on to this site. </P>
<P> The last time I log on to this site was: <span> <? Php echo date ('Y-m-d H: I: S', $ _ SESSION ['login _ time']);?>
</Span> </p> <a href = '#' id = 'logout'> [logout] </a> </p>
</Div>
<? Php} else {?>
<Div id = "login_form">
<P> <label> user name: </label> <input type = "text" class = "input" name = "user" id = "user"/> </p>
<P> <label> password: </label> <input type = "password" class = "input" name = "pass" id = "pass"/>
</P>
<Div class = "sub">
<Input type = "submit" class = "btn" value = "login"/>
</Div>
</Div>
<? Php }?>

The core code is actually

The code is as follows: Copy code

<?
If ($ _ SESSION ['user'] = 'abc ')
{

Echo 'logon successful ';

}
Else
{
Echo 'logon failed ';
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.