重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

php数据库简单登陆界面 php数据库简单登陆界面打开

如何用php做个登陆界面?

你可以做一个简单的例如你只有用户名和密码即可那么你先在数据库(以mysql为例)中建表例如叫做user 字段为 id name pass分别是编号、用户名、密码长度分别是int(8) a_t(自动编号) 主键,varchar(50) ,varchar(50) 你可以添加一个测试数据 例如 1,admin,admin//说明密码这里不说加密的问题,用明文实现 登录页面的代码:login.phphtmlheadtitle用户登录/title/headbodyform action="checklogin.php" name="loginform" method="post"用户名:input name="name" type="text"br密 码:input name="password" type="password"brinput value="登录" type="submit"br/form/body/html checklogin.php代码(检测登录): $name=$_POST[name];$pass=$_POST[password];session_start();//这个可以维持登录状态,可以参照session的使用

公司主营业务:做网站、成都网站建设、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。成都创新互联公司是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。成都创新互联公司推出老边免费做网站回馈大家。

//登录检查函数 function login_state($uid,$user_shell){ $sql="SELECT * FROM `user` WHERE `name`='$name'";

$query=@mysql_query($sql) or die(mysql_error());

$us=is_array($row=@mysql_fetch_array($query));

$user_shell=$us ? $user_shell==$row[password]:FALSE;

if($user_shell){ echo "scriptalert('登录成功');/script";

return $row;

}else{

echo "scriptalert('您暂时不能浏览该页面,请先登录');location.href='login.php';/script";

} }login_state($name,$password);?

希望可以帮到您,如果还有问题可以联系2458285853

怎么用php写一个简单的登陆页面,要连上数据库

数据库是SQLserver

?

if(isset($_GET['username']))

{

session_start();

$errormsg = "";

$input['username'] = strtolower(trim($_GET['username']));

if($errormsg == "")

{

include("db_link.php");//你自己SQL数据库所在路径

$sql = "select

user_id,

username,

status

from guestbook

where username = '".$input['username']."' and status = 1";

$result = mysql_query($sql, $link) or die('Query database failed');

$num = mysql_num_rows($result);

if($num 1)

{

$errormsg = "用户名不正确,请重新登录!";

}

else

{

$row = mysql_fetch_array($result);

if($row['username'] == $input['username'])

{

$_SESSION['s_user_id'] = $row['user_id'];

$_SESSION['s_username'] = $row['username'];

$_SESSION['s_status'] = $row['status'];

$_SESSION['time_last_load'] = time();

?

!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

html

head

title管理员登录/title

style

button,input{font-size:12px;padding-top:2px;font-family : Arial, Helvetica, sans-serif;}

a:link:{color:#666666;}

a:visited:{color:#666666;}

a:hover:{color:#000000}

/style

/head

body style="font-size: 12px;"

table width="280" border="0" cellspacing="0" cellpadding="0" align="center" style="font-size: 12px;border:1px solid #639ECE;"

trtd height="10"/td/tr

trtd height="40" align="center"登录成功!/td/tr

trtd height="10"/td/tr

trtd height="22" align="right" bgcolor="#EFFBFF"a href="javascript:void(null);" onclick="window.close();"关闭窗口/a /td/tr

/table

/body

/html

?

}

else

{

$errormsg = "用户名不正确,请重新登录!";

}

}

}

if($errormsg "")

{

?

!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

html

head

title管理员登录/title

style

button,input{font-size:12px;padding-top:2px;}

/style

/head

body style="font-size: 12px;"

table width="280" border="0" cellspacing="0" cellpadding="5" align="center" style="font-size: 12px;border:1px solid #639ECE;"

trtd height="10" colspan="2"/td/tr

form action="userlogin.php"

tr

td width="60" align="right"用户名:/td

td width="220"input type="text" name="username" value="?=$input['username']?"/td

/tr

tr

td/td

td align="center" input type="submit" value=" 登录 "/td

/tr

/form

tr

td height="10" colspan="2"/td

/tr

tr

td height="22" colspan="2" bgcolor="#EFFBFF"?=$errormsg?/td

/tr

/table

/body

/html

?

}

}

else

{

?

!--登录页面--

!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

html

head

title管理员登录/title

style

button,input{

font-size:12px;

padding-top:2px;

}

/style

/head

body

table width="280" border="0" cellspacing="0" cellpadding="5" align="center" style="font-size: 12px;border:1px solid #639ECE;"

trtd height="10" colspan="2"/td/tr

form action="userlogin.php"

tr

td width="60" align="right"用户名:/td

td width="220"input type="text" name="username"/td

/tr

tr

td/td

td align="center" input type="submit" value=" 登录 "/td

/tr

/form

trtd height="10" colspan="2"/td/tr

/table

/body

/html

?

}

?

php简单登陆系统

原理: 登陆界面为login.html, 提交表单跳转到login.php页面, 通过验证后跳转到index.php, 退出时跳转到logout.php.


网页标题:php数据库简单登陆界面 php数据库简单登陆界面打开
文章来源:http://cqcxhl.com/article/hgsosc.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP