php登录界面代码文件下载,PHP登录模板
- 建站教程
- 2024-09-26 02:47:02
本文目录一览:
怎样用PHP和MYSQL制作一简单的登录界面网站
软件:dreamwaver 记事本 也可以
mysql.php----数据库创建文件;
login.php----前台用户登陆文件;
check.php----连接数据库验证文件;
mysql.php文件代码:
程序代码
?php
$db = mysql_connect("localhost","root","") or die("连接数据库失败!");
if(!mysql_query("create database if not exists `user`"))
{
echo "创建数据库失败br";
}else
{
echo "创建数据库成功!br";
}
mysql_query("use user;");
$sql ="Create TABLE if not exists `user` ("
." `id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,"
." `name` VARCHAR(10) NOT NULL,"
." `password` VARCHAR(16) NOT NULL"
." )";
if(!mysql_query($sql))
{
echo "创建数据表失败!br";
}else
{
echo "创建数据表成功!br";
}
$sql = "Insert INTO `user` ( `name`, `password`) VALUES ( 'php-fish', '123');";
if(mysql_query($sql))
echo "插入用户成功!br";
else
echo "插入失败!br";
mysql_close($db);
?
前台登陆文件login.php
程序代码
form method="post" action="check.php"
table cellpadding="0" cellspacing="0" border="0" width="25%"
tr
td用户名:/td
tdinput type="text" name="name"/td
/tr
tr
td密码:/td
tdinput type="password" name="password"/td
/tr
tr
tdinput type="submit" value="提交"/td
tdinput type="reset" value="清除"/td
/tr
/table
/form
用户名:bphp-fish/b
br
密码:b123br
验证文件check.php
程序代码
?php
if($_POST['name'] == "")
{
echo "请填写用户名bra href='login.php'返回/a";
}elseif($_POST['password'] == "")
{
echo "请填写密码bra href='login.php'返回/a";
}else
{
$conn = mysql_connect("localhost","root","")
or die("不能连接数据库".mysql_error());
mysql_select_db("user")
or die ("不能连接到user".mysql_error());
$sql = "select * from user where id=3";
$result = mysql_query($sql);
$query = mysql_fetch_array($result);
mysql_close($conn);
if(($query['name'] == $_POST['name']) ($query['password'] == $_POST['password']))
{
echo "验证成功!br";
}else
echo "密码错误br";
echo "a href='login.php'返回/a";
}
?
求一用php写的注册和登录页面代码
reg.php文件
?php
header("Content-type:text/html;charset=utf-8");
if($_POST){
$dsn = 'mysql:dbname=1104javab;host=127.0.0.1';
$user = 'root';
$password = '';
try{
$pdo = new pdo($dsn,$user,$password,array(PDO::MYSQL_ATTR_INIT_COMMAND = 'SET NAMES 'UTF8'')
);
}catch(Exception $e){
echo '错误'.$e-getmessage();
}
$name = $_POST['name'];
$pwd = md5($_POST['pwd']);
$sql = "insert into 表 (username,password) values ('$name','$pwd')";
$exec = $pdo-query($sql);
if($exec){
echo "scriptalert('成功');location.href='reg.html'/script";
}else{
echo "scriptalert('失败');location.href='reg.html'/script";
}
}
?
reg.html文件
form action='reg.php' method='post'
用户名:input type='text' name='name'
密码:input type='password' name='pwd'
input type='submit' value='submit'
/form
login.html文件
form action='reg.php' method='post'
用户名:input type='text' name='name'
密码:input type='password' name='pwd'
input type='submit' value='submit'
/form
login.php文件
header("Content-type:text/html;charset=utf-8");
if($_POST){
$dsn = 'mysql:dbname=1104javab;host=127.0.0.1';
$user = 'root';
$password = '';
try{
$pdo = new pdo($dsn,$user,$password,array(PDO::MYSQL_ATTR_INIT_COMMAND = 'SET NAMES 'UTF8'')
);
}catch(Exception $e){
echo '错误'.$e-getmessage();
}
$name = $_POST['name'];
$pwd = $_POST['pwd'];
$sql = "select user_id from 表名 where username='$name' and password='$pwd'";
$stmt = $pdo-query($sql);
$info = $stmt-fetch(PDO::FETCH_ASSOC);
if($info){
echo "登录成功";
}else{
echo "登录失败";
}
}
大概这样
求一个PHP登陆页面代码
改完了
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""
html xmlns=""
head
meta http-equiv="Content-Type" content="text/html; charset=gb2312" /
title这里是网站的标题/title
link href="css/index.css" rel="stylesheet" type="text/css"
style type="text/css"
!--
body,td,th {
font-size: 14px;
}
a:link {
text-decoration: none;
color: #FFFFFF;
}
a:visited {
text-decoration: none;
color: #000000;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
.STYLE99 {
font-family: Georgia, "Times New Roman", Times, serif;
color: #FF00FF;
}
--
/style/head
body
div id="bigbox" class="ceng"
div id="banner" class="ceng"img src="https://www.fke6.com/html/images/banner.gif" width="778" height="70" //div
div id="main" class="ceng"
form id="form1" name="form1" method="post" action="post.php"
div id="log"
div id="logxx"span class="dazi"这里是网站的标题/span/div
div id="yonghu"用户名:
input name="user" type="text" id="user" /
/div
div id="mima"密 码:
input name="pass" type="password" id="pass" /
/div
div id="yanzheng"验证码:
input name="yz" type="text" id="yz" size="8" maxlength="4" /
?php
//$yzm = rand(1000, 9999 );
//echo $yzm;
$seedarray =microtime();
$seedstr =split(" ",$seedarray,5);
$seed =$seedstr[0]*10000;
//第二步:使用种子初始化随机数发生器
srand($seed);
//第三步:生成指定范围内的随机数
$random =rand(1000,9999);
echo "span class="STYLE99"".$random."/span";
?
input name="hiddenField" type="hidden" id="hiddenField" value="?php echo $random ?" /
/div
div id="tijiao"
input type="submit" name="Submit" value="提交" /
input type="reset" name="Submit2" value="重置" /
/div
/div
/form
/div
?php include("buttom.php");?
/div
/body
/html
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""
html xmlns=""
head
meta http-equiv="Content-Type" content="text/html; charset=gb2312" /
title这里是网站的标题 /title
link href="css/index.css" rel="stylesheet" type="text/css"
style type="text/css"
!--
body,td,th {
font-size: 14px;
}
a:link {
text-decoration: none;
color: #FFFFFF;
}
a:visited {
text-decoration: none;
color: #000000;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
--
/style/head
body
div id="bigbox" class="ceng"
div id="banner" class="ceng"img src="https://www.fke6.com/html/images/banner.gif" width="778" height="70" //div
div id="main" class="ceng"
div id="log"
div id="logxx"span class="dazi"这里是网站的标题/span/div
div id="yonghu"
?php
function make_safe($variable) {
$variable = addslashes(trim($variable));
return $variable;
}
$user=make_safe($_REQUEST["user"]);
$pass=make_safe($_REQUEST["pass"]);
$yz=make_safe($_REQUEST["yz"]);
$yzma=make_safe($_REQUEST["hiddenField"]);
if ($yz == $yzma)
{
if ($user=="" or $pass=="" or $yz =="")
{
echo"你输入的信息有空,请a href="login.php""."返回"."/a重新输入";
}
else
{
mysql_connect("localhost","root","12345") /*请修改用户名和密码*/
or die("无法连接数据库,请重来");
mysql_select_db("user")
or die("无法选择数据库,请重来");
mysql_query("SET NAMES 'gbk'");/*解决汉字*/
$row = mysql_fetch_assoc(mysql_query(" SELECT pass,xh FROM yh where name = '$user' and password = '$pass'"));
$mima=$row[password];
if($pass == $mima)
{
session_start();
$_SESSION['yhm']=$user;
echo "scriptalert('成功登陆')/script";
echo "scriptwindow.location.href='a.php';/script";
}
else
{
echo"你的用户名或者密码输入错误,请a href="login.php""."返回"."/a";
}
}
}
else
{
echo"您输入的验证码不正确!请a href="login.php""."返回"."/a";
}
?
/div
div id="mima"/div
div id="yanzheng"/div
div id="tijiao"/div
/div
/div
?php include("buttom.php");?
/div
/body
/html
求写个比较简单的php登陆页面代码
index.php 录入页代码form id="form1" name="form1" method="post" action="login.php"
table width="400" border="0" align="center" cellpadding="1" cellspacing="1" class="tableborder"
tr
tddiv align="right"用户名:/div/td
td width="244"
input type="text" name="User_name" id="User_name" / /td
/tr
tr
tddiv align="right"密 码:/div/td
tdinput type="Password" name="User_Password" id="User_Password" //td
/tr
tr
td
div align="right"
input type="submit" name="button" id="button" value="提交" /
/div/td
tdinput type="reset" name="button2" id="button2" value="重置" //td
/tr
/table
/form login.php提交页代码?
error_reporting(0);
$mysql_servername = "127.0.0.1";
$mysql_username = "root";
$mysql_password ="123456";
$mysql_database ="first";
mysql_connect($mysql_servername , $mysql_username , $mysql_password);
mysql_select_db($mysql_database);
$U_name=$_POST['user_name'];
$U_passowrd=$_POST['user_password'];
if ($U_name $U_passowrd){
$sql = "SELECT * FROM admin WHERE U_name = '$U_name' and U_password='$U_passowrd'";
$res = mysql_query($sql);
$rows=mysql_num_rows($res);
if($rows){
header("location='c.php'");
exit;
}
echo "script language=javascriptalert('用户名密码错误');history.back();/script";
}else {
echo "script language=javascriptalert('用户名密码不能为空');history.back();/script";
}
?
php登录界面代码文件下载,PHP登录模板由讯客互联建站教程栏目发布,感谢您对讯客互联的认可,以及对我们原创作品以及文章的青睐,非常欢迎各位朋友分享到个人网站或者朋友圈,但转载请说明文章出处“php登录界面代码文件下载,PHP登录模板”