Session: In computers, especially in network applications, it is called "session control". Session object stores the properties and configuration information required for a specific user session.
Login form processing (Recommended learning: PHP video tutorial)
<?php session_start(); include "inc/conn.php"; $username=$_POST[user]; $password=$_POST[pwd]; $sql=mysql_query("select * from user where username='".$username."' and password='".$password."'"); if ($result = mysql_fetch_array($sql)){ $_SESSION[username]=$username; //其他页面通过判断是否设置$_SESSION[username]来判断登录状态 ?> <scriptlanguage="javascript"> alert("登录成功");window.location.href="file.php"; </script> <?php }else{ ?> <scriptlanguage="javascript"> alert("对不起,您输入的用户名或密码不正确,请重新输入!");window.location.href="index.php"; </script> <?php } ?>
The above is the detailed content of php determines whether to log in. For more information, please follow other related articles on the PHP Chinese website!