php determines whether to log in

(*-*)浩
Release: 2023-02-27 12:02:01
Original
4133 people have browsed it

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
}
?>
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!