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 '; } |