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>