導航:首頁 > 編程語言 > php簡單的登錄界面

php簡單的登錄界面

發布時間:2022-05-12 04:00:58

A. 如何製作php登陸界面

如果你要的只是界面,那麼我給你一個好的建議。
你可以去Bootstrap官網這個裡面去找你想要的組件。
做出很炫的登錄界面。
並且提供源代碼。

凡事多動手,不要只會照搬。
我給你源代碼你也不會做。
所以,你還是多去看看如何寫。

如果,你要的是源碼,那麼你也可以去thinkphp官網去看看。有很多很不錯的代碼。值得學習。登錄界面其實很簡單,說白了,就是表單提交。

B. 用PHP語言做一個簡單的登陸頁面

恩 改了 你試試看
這個我不可能寫得直接能連接到你所要求的資料庫的,因為不知道你資料庫信息與表的設計,所以你要自己更換代碼里的hostname,db_user,password,db以及表名,欄位名,更換了應當就可以直接使用的,用戶名密碼正確與錯誤我做了修改

<?php
session_start();
$host = "localhost"; //伺服器名稱
$db_user = "root"; //用戶名
$db_password = "74862856"; //密碼
$db = "TEST"; //所要連接的資料庫
$link_id = @ mysql_connect($host,$db_user,$db_password) or die("連接資料庫失敗".mysql_error());
$db_selected = mysql_select_db($db,$link_id);
if(!$db_selected){
die("未找到指定的資料庫".mysql_error());
}

if(isset($_COOKIE['user'])){

$sql = 'select * from name where user="'.$_COOKIE['user'].'"';
$result = @ mysql_query($sql,$link_id) or die("SQL語句出錯");
$row = mysql_fetch_array($result,MYSQL_ASSOC);
if(isset($row)){ //如果資料庫中存在該用戶
Header("Location:index.php"); //合法COOKIE直接跳轉到指定界面
}else{
$_COOKIE['user'] = ""; //非法COOKIE清空
Header("Location:login.php"); //重新載入界面
}

}

if(isset($_POST['submitted'])){

$user = $_POST['user'];
$pwd = $_POST['pwd'];
$sql = 'select * from name where user="'.$user.'"';
$result = @ mysql_query($sql,$link_id) or die("SQL語句出錯");
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$cmp_pwd = $row['password'];
if($cmp_pwd == $pwd){ //用從資料庫取出的密碼和提交的密碼比較

setcookie("user",$user,time()+300); //設置COOKIE
echo "<script language=javascript>alert('登錄成功');</script>";
Header("Location:index.php"); //跳轉到指定頁面

}else{
echo "<script language=javascript>alert('用戶名或密碼錯誤');</script>";
Header("Location:login.php"); //重新載入頁面

}

}
?>

<html>
<head>
<title>登錄窗口</title>
<meta http-equiv="Content-Type" content="text/html" charset="utf8">
</head>
<body>
<form action="just.php" method="post">
用戶名:
<input type="text" name="user" />
密碼:
<input type="password" name="pwd" />
<br/>
<input type="hidden" name="submitted" value="1" />
<input type="submit" value="登錄" />
</form>
</body>
</html>

這個僅作參考,因為是非常簡化的登錄界面,沒有對提交的數據進行驗證,密碼也不是按加密處理的,COOKIE的驗證也是不安全,但整個流程的形式有了,你可以自己慢慢擴展

C. 使用php語言編寫一個登錄界面

很簡單啊,就是一個靜態頁面加一個處理PHP的程序,寫個form表單,在action提交到你要處理數據的文件,就是用$_POST獲取你表單寫的數據,然後就是寫幾個 if(){} else{}判斷,當判斷完全沒有錯誤後,就寫入資料庫,並且返回你要顯示的信息,當然,如果中途判斷你輸入的表單數據有錯,就要立即返回信息,並且 exit

D. 怎麼利用php製作簡單登入界面效果如下

<scripttype="text/javascript"src="jquery-1.7.2.min.js"></script>
<formaction="#"method="post"style="padding:20px"id="form1"><table><tr><td><labelfor="email">郵箱:</label></td><td><inputtype="text"name="email"id="email"value=""/></td></tr><tr><td><labelfor="password">密碼:</label></td><td><inputtype="password"name="password"id="password"/></td></tr><tr><td></td><td><inputtype="button"value="登陸"onclick="check_input()"/><inputname="on_submit"id="on_submit"type="hidden"value="0"/></td></table></form>

<scripttype="text/javascript">functioncheck_input(){
varpassword=$('#password').val();
varemail=$('#email').val();
varvalidatecode=$('#validatecode').val();

email=trim(email);
if(email==''){
alert('請輸入您的注冊郵箱!');
$('#mail').focus();
returnfalse;
}else{
vartag=checkEmail(email);
if(tag==false){
alert('請輸入正確的郵箱地址!');
$('#email').focus();
returnfalse;

}
}
password=trim(password);
if(password==''){
alert('請輸入您的密碼!');
$('#password').focus();
returnfalse;
}

validatecode=trim(validatecode);
if(validatecode==''){
alert('請輸入驗證碼!');
$('#validatecode').focus();
returnfalse;
}
$('#on_submit').val(1);
$('#form1').submit();
}

//email判斷
functioncheckEmail(cEmail)
{
vararr=cEmail.split('@');
varc=true;
if(arr.length!=2)
c=false;
elseif(!arr[0].length||!arr[1].length)
c=false;
elseif(arr[1].split('.').length<2)
c=false;
elseif(!arr[1].split('.')[0].length||arr[1].split('.')[1].length<2||arr[1].split('.')[1].length>4)
c=false;
returnc;
}
functiontrim(str){
returnrtrim(ltrim(str));
}
functionltrim(s){
returns.replace(/(^s*)/g,"");
}
//去右空格;
functionrtrim(s){
returns.replace(/(s*$)/g,"");
}
</script>

拿去改改就能用了!!

E. 如何用php做個登陸界面

你可以做一個簡單的例如你只有用戶名和密碼即可那麼你先在資料庫(以mysql為例)中建表例如叫做user 欄位為 id name pass分別是編號、用戶名、密碼長度分別是int(8) a_t(自動編號) 主鍵,varchar(50) ,varchar(50) 你可以添加一個測試數據 例如 1,admin,admin//說明密碼這里不說加密的問題,用明文實現 登錄頁面的代碼:login.php<html><head><title>用戶登錄</title></head><body><form action="checklogin.php" name="loginform" method="post">用戶名:<input name="name" type="text"><br>密 碼:<input name="password" type="password"><br><input value="登錄" type="submit"><br></form></body></html> checklogin.php代碼(檢測登錄): $name=$_POST[name];$pass=$_POST[password];session_start();//這個可以維持登錄狀態,可以參照session的使用
//登錄檢查函數 function login_state($uid,$user_shell){ $sql="SELECT * FROM `user` WHERE `name`='$name'";
$query=@mysql_query($sql) or die(mysql_error());
$us=is_array($row=@mysql_fetch_array($query));
$user_shell=$us ? $user_shell==$row[password]:FALSE;
if($user_shell){ echo "<script>alert('登錄成功');</script>";
return $row;
}else{
echo "<script>alert('您暫時不能瀏覽該頁面,請先登錄');location.href='login.php';</script>";
} }login_state($name,$password);?>
希望可以幫到您,如果還有問題可以聯系2458285853

F. 用php寫一個簡單登錄界面,怎麼給它加入一張背景圖片啊,用div框該怎麼弄,或者其他的方法

背景圖像載入很簡單,你只需要做以下幾步即可(假設你的登陸界面對話框類名叫「CLoginDlg」):
(1)菜單「Insert」->"Resource",選擇Bitmap,然後點「Import...」,選擇你的背景圖像,然後假設該資源ID為「IDB_BITMAP1」;
(2)在LoginDlg.h下聲明一個CBitmap m_BKbitmap;
(3)在LoginDlg.cpp的構造函數中:m_BKbitmap.LoadBitmap(IDB_BITMAP1);
(4)在LoginDlg.cpp的OnPaint()函數中寫上:
void CLoginDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
if (IsIconic())
{
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;

// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
BITMAP bm;
CRect rect;
CDC dcMem;
m_BKbitmap.GetBitmap (&bm);
GetClientRect(&rect);
dcMem.CreateCompatibleDC (&dc);
CBitmap *oldbitmap=dcMem.SelectObject (&m_BKbitmap);
dc.BitBlt (0,0,bm.bmWidth ,bm.bmHeight ,&dcMem,0,0,SRCCOPY);
dcMem.SelectObject(oldbitmap);
CDialog::OnPaint();
}
}
你的問題就OK了。
關於按鈕控制項顯示圖片,建議你可以下載一個CButton的繼承類,什麼「CButtonST」啊、「CBtnST」啊、「CDlgShadeButtonST」啊,自己手寫的話不劃算,有很多現成的控制項類,都寫的非常好,完全可以拿來為我們所用。

G. 做一個簡單的php 注冊登陸界面

你會php嗎?會的話這邊給你個思路,然後根據這思路來寫。首先注冊效果是;1、做好注冊頁面,放置你要的表單,給你的每一個表單取一個名字(名字自定義,不重復即可)。2、用$_post或$_get來提交到php接收頁面。3、在php頁面裡面首先是接收你注冊頁面過來的信息,用$_POST["表單名字"]或$_GET["表單名字"]方法來接。4、執行sql語句了,把接過來的內容寫進資料庫就ok了。(insert into );登陸頁就是提交過來的數據跟資料庫裡面的數據進行比對的過程,這個沒多少代碼。把提交過來的數據,通過php接過來之後跟資料庫裡面的資料庫進行查找比對。一致就登陸成功,否則登陸失敗。

H. 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>";
}
?>
不過你需要連接到你自己的指定的資料庫和數據表。

I. 請詳解以下PHP代碼 ,簡單的登陸界面

<?php
include("conn.php");//引用文件

if ($_GET[out]){//獲取參數
setcookie("cookie","out");//設置為緩存
echo"<script language=\"javascript\">location.href='login.php';</script>";//轉到登錄界面
}
if ($_POST[id] == 'admin'){//獲取參數如果是admin就執行下面
$pw=md5($_POST[pw]);//對密碼進行加密
if($pw ==md5('abc')){//對abc進行加密加密完的值與獲取的密碼參數做對比
setcookie("cookie","ok");//設置為緩存
echo "<script language=\"javascript\">location.href='login.php';</script>";//轉到登錄界面
}
}
include("head.php");//引用文件
if($_COOKIE['cookie'] != 'ok'){//判斷緩存值
?>
夠詳細了吧!

J. PHP寫登陸界面!

首先要有HTML基礎,了解什麼是form,如何編輯窗體。
登陸界面HTML就能寫出來,可以借鑒任何一個網站的代碼,抄上去就有了一個界面。
在了解form的基礎上使用post或者get發送數據。將數據保存在name屬性的value中(自查)
然後在另外的php頁面中,使用$_GET或者$_POST獲取數據。
獲取數據後,從mysql獲取數據然後比較即可。
安全考慮注意過濾數據。

閱讀全文

與php簡單的登錄界面相關的資料

熱點內容
手機號碼如何加密 瀏覽:424
沈陽程序員培訓學校 瀏覽:538
一般伺服器如何配置 瀏覽:895
圖片怎樣加密發郵件 瀏覽:619
萬虹電腦文件夾密碼忘記了怎麼辦 瀏覽:631
rc108單片機 瀏覽:867
戰雷如何改變伺服器 瀏覽:674
mactelnet命令 瀏覽:51
壓縮袋壓縮了拿出來 瀏覽:401
安卓手機相機怎麼設置許可權 瀏覽:121
美女程序員轉行做主播 瀏覽:671
辦理解壓房產 瀏覽:575
道路工程概論pdf 瀏覽:388
超棒數學速演算法大全 瀏覽:937
小米易語言登錄源碼 瀏覽:31
磚牆內加密鋼筋 瀏覽:992
鄉關何處pdf 瀏覽:84
小豬領贊小程序源碼 瀏覽:336
python曲線如何原路返回 瀏覽:430
pdf快速看圖破解版 瀏覽:294