Home >Backend Development >PHP Problem >php determines whether to log in

php determines whether to log in

(*-*)浩
(*-*)浩Original
2019-10-19 11:06:504221browse

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.

php determines whether to log in

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=&#39;".$username."&#39; and password=&#39;".$password."&#39;");
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!

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
Previous article:What is php in lnmpNext article:What is php in lnmp