php实现管理员登录功能

WBOY
Release: 2016-06-20 12:46:34
Original
1011 people have browsed it

   打开Dreamweaver cs6,添加以下代码:


if($_POST[user])                 //判断是否输入用户名

{

$name=$_POST["user"];                 //获取登录用户名

$pass=$_POST["pass"];                 //获取登录密码

require "ch16-1.php";                  //引用配置文件

$link=mysql_connect($db_host,$db_user,$db_pass) or die(mysql_error());

mysql_select_db($db_name,$link);

$sql="select * from $table_user where u_name='$name' && u_pass='$pass'";

$result=mysql_query($sql);                 //发送SQL请求

if(@mysql_num_rows($result)!=0)           //若找到符合条件的用户与密码

{

setcookie("name","$name",time()+60*60*24);   //创建COOKIE

echo "

";

echo "";

echo "";

echo "

Related labels:
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