当前位置:首页 » 编程语言 » php登录页面

php登录页面

发布时间: 2022-02-11 21:50:29

‘壹’ 求写个比较简单的php登陆页面代码

主页面:index.php <form name="form1" action="login.php" method="post" onsubmit="return check()"><!--这里注意onclick的用法-->
账号:<input name="adminAccount" type="text" />

密码:<input type="password" name="adminPass" />

输入验证码:<input type="text" name="validate" />
< br />
<input type="submit" value="登陆" /><input type="reset" value="重置">
</form>判断页面:login.php<?php
//再连库判断账号密码
require_once("../inc/dbconfig.php");
$adminAccount=$_POST['adminAccount'];
$adminPass=md5($_POST['adminPass']);
$sql="select * from admin where adminAccount='$adminAccount' and adminPass='$adminPass'";
$result=mysql_query($sql) or die($sql);
$rows=mysql_num_rows($result);
if($rows==0){
?>
<script language="javascript">
alert("管理员账号密码错误!");
window.location="index.php";
</script>
<?
exit();
}
//将管理员账号赋值给session
$_SESSION['adminAccount']=$adminAccount;
?>
<script language="javascript">
window.location="command.php";
</script>配置文件自己来就行了!

‘贰’ php登录页面的是怎么做的

session_star();
if(!isset($_SESSION['login_status']))//不存在就直接login页面,你可以在每个页头加载这个来判断
header('Location:login.php');
$username=$_POST['name'];
$pass=$_POST['password'];

$sql="select*from用户表单whereusername='{$username}'";
$result=mysql_query($sql,$link);

if($result&&mysql_num_rows($result)>0){//判断用户名是否存在
$user=mysql_fetch_assoc($result);
if($user['pass']==md5($pass)){
$_SESSION['login_status']=1//让后续判断是不是已经登录了(存放在服务器端,关闭浏览器就没有,或者你可以用cookie来判断)
echo'登录成功!';
}else{
echo"密码错误!";
}
}else{
echo"账号不存在!";
}

‘叁’ 用php制作用户登录认证网页

将用户名和密码提交到指定的页面,如checkform.php,然后在该页面中以传来的用户名和密码为条件,在数据库中查找,如果有记录的话,成功登陆,如果没有,就说明没有该用户,活着用户名错误

‘肆’ PHP写登陆界面!

首先要有HTML基础,了解什么是form,如何编辑窗体。
登陆界面HTML就能写出来,可以借鉴任何一个网站的代码,抄上去就有了一个界面。
在了解form的基础上使用post或者get发送数据。将数据保存在name属性的value中(自查)
然后在另外的php页面中,使用$_GET或者$_POST获取数据。
获取数据后,从mysql获取数据然后比较即可。
安全考虑注意过滤数据。

‘伍’ php登录页面 点击登录后页面空白

注册提交的页面是什么和login.php有没有关系
注册是注册 登录是登录的 完全没有关联是不行的 除非是注册完毕后页面跳转到登录页面
注册后想直接登录 需要把帐号和密码组成参数类型传递到login.php
login.php这样判断就要有两种形式 一种是表单提交的形式 一种就是参数传递的形式
更多问题到后盾网论坛问题求助专区http://bbs.hounwang.com/

‘陆’ 如何制作php登陆界面

如果你要的只是界面,那么我给你一个好的建议。
你可以去Bootstrap官网这个里面去找你想要的组件。
做出很炫的登录界面。
并且提供源代码。

凡事多动手,不要只会照搬。
我给你源代码你也不会做。
所以,你还是多去看看如何写。

如果,你要的是源码,那么你也可以去thinkphp官网去看看。有很多很不错的代码。值得学习。登录界面其实很简单,说白了,就是表单提交。

‘柒’ html+php+mysql的登录页面

header("Content-Type:text/html;charset=utf-8");
$lune=$_POST["username"];
$lpwd=$_POST["password"];

include("conn.php");

$query="select*fromuserlistwhereusername='$lune'andpassword='$lpwd'";
$result=mysqli_query($link,$query);
if(mysqli_num_rows($result)==1){
$row=mysqli_fetch_array($result);
$json=array('lzhuangtai'=>'y','lname'=>$lune,'ldianhao'=>$row[phone],'ltishi'=>'用户验证成功');
}
else{
$json=array('lzhuangtai'=>'n','ltishi'=>'用户名或密码无效');
}

$json_string=json_encode($json);
echo$json_string;

你的代码,$row['phone']这里是单引号,外边也是,所以就出错了。直接不用引号,或者换成双引号。

‘捌’ php登陆页面完整代码

PHP登陆后跳转到登陆前页面,利用$_SERVER全局变量可以实现这个功能,下面有个不错的示例,希望对大家有所帮助
最近手上一个小项目让我接触到PHP编程,简单的登陆功能已经OK。可是在实际使用的时候发现一个问题:用户A发送一个链接给用户B,B打开时页面提示登陆,可是登陆成功后,却跳转到了首页,而并不是A发送的链接。为了有更好的用户体验,B登陆成功后应该自动跳转到登陆前的链接。查了PHP帮助手册,利用$_SERVER全局变量可以实现这个功能。 $_SERVER是PHP的一个超全局变量,关于$_SERVER变量的详细解释可以参考:http://www.php.net/manual/zh/reserved.variables.server.php 具体实现方法为:在提示用户登录的同时,在session或者cookie中记录下请求页面的URL;登录验证成功后在跳转回该URL。 checklogin.php 代码如下: session_start(); if (!isset ($_SESSION['login_ok'])) { echo "<script language=javascript>alert ('要访问的页面需要先登录。');</script>"; $_SESSION['userurl'] = $_SERVER['REQUEST_URI']; echo '<script language=javascript>window.location.href="login.php"</script>'; } login.php 代码如下: session_start(); //此处省略了账号密码验证代码,验证OK再执行下面代码 if (isset ($_SESSION['userurl'])) { //会话中有要跳转的页面 $url = $_SESSION['userurl']; } else { //没有要跳转的页面,则转到首页 $url = "home.php"; } //0.5s后跳转 echo "<meta http-equiv="refresh" content="0.5;url=$url">";

‘玖’ 用PHP做登陆注册页面

登录页:login.php
<?php
include("conn.php");
$username=$_POST['name'];
$password=$_POST['password'];
$yanzheng=$_POST['yanzheng'];

if(isset($_POST['submit']))
{
$sql=("select username,password from member where username='$username' and password='$password'") or die("sql语句执行失败");
//print_r($sql);
$ar=mysql_query($sql);
if($ar)
{
if($row=mysql_fetch_array($ar))
{
session_start();
if($_POST["yanzheng"])
{
if($yanzheng!=$_session[pic]||$yanzheng=="")
{
echo "验证码输入有误";
exit;
}
if($yanzheng==$_session[pic])
{
header("location:index.php");
}
}
}
else
{
echo "用户名或密码错误";
}
}
}

?>

<form action="login.php" method="post">
<table border=1 align=center width=500 height=300 bgColor=#DFFFDF bordercolor=#fffbec>
<tr>
<td colspan=2 align=center>用户登录</td>
</tr>
<tr>
<td>用户姓名:</td>
<td><input type="text" name="name" id="name"/></td>
</tr>
<tr>
<td>用户密码:</td>
<td><input type="password" name="password" id="password"/></td>
</tr>
<tr>
<td>验证码:</td>
<td><input type="text" name="yanzheng" id="yanzheng"/>
<img src="yanzheng1.php" width="50" height="30"></img>
</td>
</tr>
<tr>
<td colspan=3 align=center>
<input type="submit" name="submit" value="登录"/>
<input type="reset" name="reset" value="重置"/>
<a href="register.php">注册</a>
</td>
</tr>
</table>
</form>

注册页:register.php

<?php
include("conn.php");
if(isset($_POST['submit'])&&$_POST['submit']) {
if($_POST['username']=='')
{
echo "用户名不能为空";
exit();
}
if($_POST['password']=='')
{
echo "密码不能为空";
exit();
}
if($_POST['realpass']!=$_POST['password'])
{
echo "两次密码输入不一致";
exit();
}

$sql="insert into member(username,real_name,password,email,headimg) values('$_POST[username]','$_POST[username]','$_POST[password]','$_POST[email]','')";
$ar=mysql_query($sql);
if($ar)
{
header("location:index.php");
}
else
{
echo mysql_error();
}
}
?>
<body>
<form action="register.php" method="post">
<table border=1 align=center width=500>
<tr>
<td height=40 bgColor=#DFFFDF colspan=2>会员注册 [<a href="login.php">返回登录页</a>]</td>
</tr>
<tr>
<td height=40 bgColor=#fffbec >会员ID</td>
<td><input type="text" name="username" id="username"/></td>
</tr>
<tr>
<td height=40 bgColor=#fffbec>密码</td>
<td><input type="password" name="password" id="password"/></td>
</tr>
<tr>
<td height=40 bgColor=#fffbec>确认密码</td>
<td>
<input type="password" name="realpass" id="realpass"/>
</td>
</tr>
<tr>
<td height=40 bgColor=#fffbec>EMAIL</td>
<td><input type="text" name="email" id="email"/>

</tr>
<tr>
<td height=40 bgColor=#fffbec></td>
<td><input type="submit" name="submit" value="注册"/><input type="reset" value="重置"></td>
</tr>
</table>
</form>
</body>

主页显示:index.php
<?php
include("conn.php");
function cutstr($str,$cutleng)
{
$str = $str; //要截取的字符串
$cutleng = $cutleng; //要截取的长度
$strleng = strlen($str); //字符串长度
if($cutleng>$strleng)return $str;//字符串长度小于规定字数时,返回字符串本身
$notchinanum = 0; //初始不是汉字的字符数
for($i=0;$i<$cutleng;$i++)
{
if(ord(substr($str,$i,1))<=128)
{
$notchinanum++;
}
}
if(($cutleng%2==1)&&($notchinanum%2==0)) //如果要截取奇数个字符,所要截取长度范围内的字符必须含奇数个非汉字,否则截取的长度加一
{
$cutleng++;
}
if(($cutleng%2==0)&&($notchinanum%2==1)) //如果要截取偶数个字符,所要截取长度范围内的字符必须含偶数个非汉字,否则截取的长度加一
{
$cutleng++;
}
return substr($str,0,$cutleng);
}
?>
<html>
<head>
<script type="text/javascript">
function All(e, itemName)
{
var aa = document.getElementsByName(itemName);
for (var i=0; i<aa.length; i++)
aa[i].checked = e.checked; //得到那个总控的复选框的选中状态
}
function Item(e, allName)
{
var all = document.getElementsByName(allName)[0];
if(!e.checked) all.checked = false;
else
{
var aa = document.getElementsByName(e.name);
for (var i=0; i<aa.length; i++)
if(!aa[i].checked) return;
all.checked = true;
}
}
</script>
</head>
<?php
include("conn.php");
if(isset($_POST['del']))
{
$mm = $_POST["selected"];
$id =implode(",",$mm);
$sql = "delete from forums where id in(".$id.")";
//echo $sql;
$result=mysql_query($sql);
echo $result?"删除成功":"删除失败";
}
?>
<table style="BORDER-BOTTOM-WIDTH: 1px; BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 width=600 align=center border=1 bordercolor=#ddddff>
<tr align=middle>
<td height=40 bgColor=#DFFFDF colspan=3>论坛列表</td>
</tr>
<tr>
<td colspan=3><a href="login.php" style="float:right">[退出系统]</a><a href="add_forum.php" style="float:right">[添加论坛]</a></td>
<td></td>
</tr>
<tr align=middle>
<td height=40 bgColor=#DFFFDF width=80>状态</td>
<td height=40 bgColor=#DFFFDF>论坛</td>
<td height=40 bgColor=#DFFFDF>最后更新</td>
</tr>
<?php
$sql="select * from forums";
$result=mysql_query($sql);
$num=mysql_num_rows($result);
if($num>0)
{
while($row=mysql_fetch_array($result)){
?>
<tr align=middle>
<td bgColor=#fffbec><input type="checkbox" name="selected" value="1"/></td>
<td height=50 bgColor=#fffbec width=300>
<?php
echo "<div><a href=\"forums.php?F=".$row['ID']."\">".$row['forum_name']."</a></div>";
echo cutstr($row['forum_description'],24);//最多显示24个字节,12个字,多余部分用省略号代替
echo "……";
?>
</td>
<td height=50 bgColor=#fffbec><div><?php echo $row['last_post_time']."by".$row['last_post_author']?></div></td>

</tr>
<?php
}
}
else
{
echo "<tr bgColor=#fffbec><td colspan=3>对不起,论坛尚在创建中……</td></tr>";
}
?>
<tr>
<td colspan=3> <input type="checkbox" name="selected" value="1" onclick="All(this,'selected')"/>全选/不全选</td>
</tr>
<tr>
<td><input type="button" name="del" id="del" value="删除选中项"/>
<?php

?>
</td>
</tr>
</table>
</html>

数据库你就自己建,望采纳~

‘拾’ PHP做一个用户登录页面

index.html登录页面代码如下:
<!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=gb2312" />
<title>登录示例</title>
</head>

<body>
<form id="forms" name="forms" method="post" action="loginchk.php">
用户名:<input type="text" id="uname" name="uname" value=""/><br/>
密码:<input type="password" id="upass" name="upass" value=""/><br/>
<input type="submit" id="loginbtn" value="立即登录"/>
<input type="reset" id="resetbtn" value="重新填写"/>
</form>
</body>
</html>

loginchk.php 的PHP程序代码如下:
<?php
$uname=trim($_REQUEST["uname"]);
$upass=trim($_REQUEST["upass"]);
if($uname=="admin"&&$upass=="admin")
{
echo "登录成功";
}
else
{
echo "登录失败,<a href='index.html'>重新登录</a>";
}
?>

以上只是一个简单示例,真正的开始,需要考到很多因素,比如说登录前有效性检查,加入登录验证码,程序需要连接数据库进行用户匹配等。
希望对你有帮助 。
如果使用数据库进行进行匹配的话,PHP程序可以这样改进一下。
<?php
$uname=trim($_REQUEST["uname"]);
$upass=trim($_REQUEST["upass"]);

$con = mysql_connect("localhost","root","root");
mysql_select_db("dbname", $con);
$result = mysql_query("select * from sers where uname='$uname' and upass='$upass'");
$rs = mysql_fetch_array($result);
if($rs)
{
echo "登录成功";
}
else
{
echo "登录失败,<a href='index.html'>重新登录</a>";
}
?>
不过你需要连接到你自己的指定的数据库和数据表。

热点内容
新一代唐dm哪个配置最划算 发布:2024-05-02 22:45:16 浏览:229
安卓怎么安装到sd卡 发布:2024-05-02 22:41:32 浏览:224
web聊天源码 发布:2024-05-02 22:41:29 浏览:286
php定时脚本 发布:2024-05-02 22:18:41 浏览:312
云服务可以替代普通服务器么 发布:2024-05-02 21:57:11 浏览:944
wegame与服务器断开连接是怎么回事 发布:2024-05-02 21:55:05 浏览:785
zip加密破解 发布:2024-05-02 21:41:23 浏览:480
怎么模拟电脑配置 发布:2024-05-02 21:28:08 浏览:784
对一个新编程 发布:2024-05-02 21:20:07 浏览:559
华为系统编译器在哪里 发布:2024-05-02 21:19:50 浏览:86