php用户登录代码
发布:smiling 来源: PHP粉丝网 添加日期:2014-01-15 10:45:26 浏览: 评论:0
一款讲得非常详细的登录代码,对php入门者有很大的帮助,有需要的朋友可以免费查看,效果图如下:
index.php,代码如下:
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=gbk" />
- <title>系统登录</title>
- <link href="css.css" rel="stylesheet" type="text/css" />
- </head>
- <body>
- <div id="box">
- <div id="denglu">
- <div id="pic"> 系统后台登陆</div>
- <form action="check.php" method="post">
- <p>用户名:
- <input type="text" name="name" id="name" />
- <span class="must">*</span></p>
- <p>密 码:
- <input name="password" type="password" id="password" />
- <span class="must">*</span></p>
- <p>验证码:
- <input name="check" type="text" id="check" size="8" />
- <img src="piccheck.php" /> <span class="must">*</span></p>
- <p class="form_button">
- <input type="submit" name="sub" id="sub" value="登陆" />
- <input type="reset" name="unsub" id="unsub" value="取消" />
- </p>
- </form>
- </div>
- </div>
- </body>
- </html>
数据库连接connect.php,代码如下:
- <?php
- $connect=mysql_connect("localhost","root","")or die("服务器连接失败");
- mysql_select_db("test",$connect)or die("没有建立相应的数据库");
- $sql="select * from admin";
- ?>
图片验证码 piccheck.php,代码如下:
- <?php
- /*
- * Created on 2011-8-10
- *
- * To change the template for this generated file go to
- * Window - Preferences - PHPeclipse - PHP - Code Templates
- */
- session_start();
- $code=rand(0,9).dechex(rand(10,15)).rand(0,9).dechex(rand(10,15));
- $_SESSION[pic]=$code;
- $image=imagecreatetruecolor(50,18);
- $color=imagecolorallocate($image,0,0,0);//第一次使用调色板,会设为背景颜色
- $colortext=imagecolorallocate($image,rand(100,255),rand(100,255),rand(100,255));
- imagestring($image,10,rand(1,15),rand(1,5),$code,$colortext);
- imagegif($image);
- ?>
css.css文件,代码如下:
- @charset "utf-8";
- /* CSS Document */
- body {
- background-color: #9CF;
- text-align: left;
- }
- #denglu {
- width: 400px;
- margin-top: 0px;
- margin-right: auto;
- margin-bottom: 0px;
- margin-left: auto;
- background-image: url(images/login.gif);
- background-repeat: no-repeat;
- height: 320px;
- text-indent: 6px;
- }
- #box #denglu form {
- position: relative;
- top: 50px;
- left: 10px;
- width: 92%;
- }
- .must {
- color: #F00;
- font-size: 12px;
- }
- #box #denglu #pic {
- background-image: url(images/dot1.gif);
- background-repeat: no-repeat;
- height: 20px;
- width: 100px;
- font-size: 12px;
- color: #F00;
- text-align: left;
- line-height: 18px;
- left: 10px;
- top: 30px;
- position: relative;
- }
Tags: php 用户登录 代码
- 上一篇:完整的新闻无限级分类代码,可添加,删除,移动,修改
- 下一篇:图片验证码生成应用实例
相关文章
- ·PHP+TEXT留言本(一)(2013-11-11)
- ·PHP+TEXT留言本(二)(2013-11-11)
- ·PHP+TEXT留言本(三)(2013-11-11)
- ·PHP+TEXT留言本(四)(2013-11-11)
- ·PHP+TEXT留言本(五)(2013-11-11)
- ·PHP+TEXT留言本(六)(2013-11-11)
- ·PHP+MYSQL留言本(一)(2013-11-16)
- ·PHP+MYSQL留言本(二)(2013-11-16)
- ·PHP+MYSQL留言本(三)(2013-11-16)
- ·PHP设计聊天室步步通(一)(2013-11-16)
- ·PHP设计聊天室步步通(二) (2013-11-16)
- ·PHP设计聊天室步步通(三) (2013-11-16)
- ·PHP设计聊天室步步通(四) (2013-11-16)
- ·php注册页面代码(mysql+php)(2013-12-11)
- ·php 用户注册页面代码(2013-12-11)
- ·php写的网页计数器代码(2013-12-11)
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)