php登录程序代码

<?php
session_start();//必须在最前面,否则 会出错!!
if(empty($_POST["username"])){
echo ("<script type='text/javascript'> alert('用户名怎么能是空的呢!');history.go(-1);</script>");
}
if(empty($_POST["userpass"])){
echo ("<script type='text/javascript'> alert('密码也不能是空的!');history.go(-1);</script>");
}
$username= $_SESSION["username"]; // 这个地方 应该是session 吧!
$userpass= $_SESSION["userpass"]; //
$db=mysql_connect('localhost','root','root');
mysql_select_db(secretdata,$db);
//$sql="select*from whoareyou where username='$username' and userpass='$userpass'";
$result=mysql_query("select * from whoareyou where
username='$username' and userpass='$userpass'");
//if($_POST['username']=="username" and $_POST['userpass']=="userpass") {
if(!$result){
echo ("<script type='text/javascript'> alert('用户名或密码不正确!');history.go(-1);</script>");
//mysql_close();
exit;
}

$_SESSION["username"]="$username";
echo "<script>location.href='find.php';</script>"; //这个地方 注释有误!

echo "".$username."你已经登录成功了!!!";
mysql_close();
?>

你的程序有3个地方 明显的错了! 你试试这样行吗?

Ⅱ php登录页面

你要怎么样才算用户名密码正确?连数据库还是只要不为空就算正确?

Ⅲ 求写个比较简单的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登陆页面代码

改完了

<!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>
<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="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" "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>
<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="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 "<script>alert('成功登陆')</script>";
echo "<script>window.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网站登录注册源码

//login.php 负责处理用户登录与退出动作
if(!isset($_POST['submit'])){
exit('非法访问!');
}
$username = htmlspecialchars($_POST['username']);
$password = MD5($_POST['password']);

//包含数据库连接文件
include('conn.php');
//检测用户名及密码是否正确
$check_query = mysql_query("select uid from user where username='$username' and password='$password' limit 1");
if($result = mysql_fetch_array($check_query)){
//登录成功
$_SESSION['username'] = $username;
$_SESSION['userid'] = $result['uid'];
echo $username,' 欢迎你!进入 <a href="my.php">用户中心</a>
';
echo '点击此处 <a href="login.php?action=logout">注销</a> 登录!
';
exit;
} else {
exit('登录失败!点击此处 <a href="javascript:history.back(-1);">返回</a> 重试');
}
注:上述源码是在TP中的登录验证方法,供参考!!

Ⅵ PHP实现用户登录验证源码

您可以参考一下Discuz!7.2版中的登录验证,这要比另外写强的多。

Ⅶ 求php源代码,实现登陆退出

......你这个啊 随便找个cms 系统 找到 对应的 login 看看把

Ⅷ 用PHP做网站后台管理登陆界面详细代码

给你点思路,若是不懂的话你可以hi我。

Ⅸ php登陆验证页面代码

<?php
if(isset($_POST)){
if($_POST['password']=="123"){
header("Location: http://要跳转的页面");
}else{
header("Location: http://要跳转的页面");
}
}
?>
<form action="register.php" method="post">
密码:<input type="password" name="password">

<input type="submit" name="submit" value="submit me!" />
</form>

Ⅹ 求一个php的登陆源码。功能简单就行

index.php
<html>
<head>
<title>登录界面</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<?php
//将用户提交的用户名和密码和数据库中的用户名和密码逐一比对,如正确,则进入2.php,错误则提示错误。
$username=$_post['username'];
$password=$_post['password'];
$sql="select * from userinfo where username='$username' and password='$password'";
$re=mysql_query($sql);
$row=mysql_num_rows[$re];
if(!$row){
echo "<script>alert('用户名或密码错误!');history.back(-1);</script>";
}
else {
echo '用户登录成功!';
echo '<meta http-equiv=refresh content=2;url=2.php>';
}
?>
<form name="login" method="post" action="index.php">
用户名:<input type="text" name="username" /><br/>
密码:<input type="password" name="password" /><br/>
<input type="submit" name="submit" value="登录">
</form>
</body>
<html>