一个简单的php用户登陆模块
时间:2021-07-01 10:21:17
帮助过:19人阅读
-
-
-
-
- 登陆系统
-
-
- session_start();
- if ($_SESSION[username]) {
- ?>
-
- }else {
- ?>
-
- }
- ?>
-
-
2,config.php
- $dbhost="localhost";
- $dbuser="root";
- $dbpassword="123456";
- $dbname="auth";
- $conn=mysql_connect("$dbhost","$dbuser","$dbpassword") or die('不能连接服务器'.mysql_error());
- mysql_select_db("$dbname",$conn) or die("数据库访问错误".mysql_errno());
- mysql_query("set names gb2312");
- ?>
3,userlogin.php
-
-
-
-
- 登陆系统_bbs.it-home.org
-
-
- session_start();
- require("config.auth.php");
- if ($_POST[submit]) {
- $sql="select * from userinfo where username = '$_POST[username]' and password = '$_POST[password]'";
- $result=mysql_query($sql);
- $numrows=mysql_num_rows($result);
- if ($numrows == 1) {
- $row=mysql_fetch_assoc($result);
- $_SESSION[username]=$row[username];
- //echo $_SESSION[username];
- echo "";
- }else {
- echo "
|