導航:首頁 > 編程語言 > php登陸注冊功能實現

php登陸注冊功能實現

發布時間:2022-04-11 05:08:37

php連接myadmin資料庫實現登入注冊

你是哪部分不會,資料庫連接正常不寫好了沒?資料庫表設計好了沒?注冊登錄頁面前端寫好了沒?用session就可以實現登錄了,然後就是你其他頁面了,沒開發好,可以代開發

Ⅱ PHP如何實現注冊和登錄

注冊頁面前面加個下拉框或者單選按鈕,然後把值傳過去,登錄的時候也選擇,傳值,然後在相應的分類查找這個人。注冊頁面前面加個下拉框或者單選按鈕,然後把值傳過去,登錄的時候也選擇,傳值,然後在相應的分類查找這個人。

Ⅲ PHP怎麼實現登錄和注冊

<?php
if($_GET['user']=='admin'&&$_GET['pwd']=='123')
echo'登陸成功';
?>
<formaction=""method="get"/>
<tableborder="0"cellspacing="0"cellpadding="0">
<tr>
<tdclass="fieldKey"width="30%">用戶名:</td>
<tdclass="fieldValue"width="100%"><inputtype="text"name="user"/></td>
</tr>
<tr><tdheight="10"></td></tr>
<tr>
<tdclass="fieldKey">密碼:</td>
<tdclass="fieldValue"><inputtype="password"name="pwd"/></td>
</tr>
</table>
<inputtype="submit"value="登陸"/>
</form>

寫了一個超級簡單的,

Ⅳ 用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

<script language="javascript">
function checkpost()
{
if(loginform.user.value =="")

{
alert("用戶名不能為空!");
loginform.user.focus();
return false;

}

if(loginform.pw.value =="")

{
alert("密碼不能為空!");
loginform.pw.focus();
return false;

}

}<script> 用戶登錄
</tr>
<tr>
<td height="169" bgcolor="#F9F9F9" style="color:#CCCCCC"><form action="login.php" method="post" onSubmit="return checkpost();" name="loginform"><div><span class="class9"> <font color="#000000">用戶名:</font></span><input name="user" type="text" size="15" />
</div> <div><span class="class9"> <font color="#000000">密 碼:</font></span><input name="pw" type="password" size="15" />
</div>

<div align="center"><input type="submit" name="sub" value="登錄" /> <input type="reset" value="重置" /></div>
<div align="center" class="syCss"><a href="username1.php" target="_blank">注冊</a></div>
</form></td> login.php<?php
session_start();

$username =trim( $_POST['user']);
$password =trim( $_POST['pw']);
if((empty($username)) || (empty($password)))
{
echo "<script language=\"JavaScript\">alert('用戶名或者密碼不能為空!');history.back();</script>";
}
else
{
$myconn = mysql_connect("localhost", "root", "");
mysql_query("SET NAMES 'GBK'");
mysql_select_db("users") or die ("不能連接到資料庫!");

//判斷用戶名和密碼是否在正確
$strSql="select * from test where username='$username' and password='$password'";
$result=mysql_query($strSql) or die("讀取資料庫出現錯誤!");
$num=mysql_num_rows($result);

if($num<0)
{
echo "該用戶不存在!";

}
else
{
$row = mysql_fetch_array($result);
if(($row['username'] == $username) && ($row['password'] == $password ) )

{
$name = "歡迎您:";
$_SESSION[username] = $name. $username;

$quit = "退出";
$_SESSION[quit] = $quit;
echo "<script language=\"JavaScript\">alert('登錄成功!');window.location.href=\"index.php\";</script>";

}
else
{
if(($row['username'] != $username) || ($row['password'] != $password ) )
{
echo "<script language=\"JavaScript\">alert('用戶名或者密碼錯誤!');history.back();</script>";
}

else
{
echo "<script language=\"JavaScript\">alert('登錄失敗!');history.back();</script>";
}

}

}

mysql_close($myconn);
}
?><a href= http://www.xiaohouse.com>小房子</a>

Ⅵ PHP+MySQL 實現簡單的登錄注冊

你好,這個我做過。我給你說下思路。
首先表單post提交,然後:
$password=$_post['password'
if($password){
$sql=select * from 'admin' where 'password'=$password
}else{
echo 『密碼錯誤』
exit()
}
這是簡單思路,注冊也差不多。

Ⅶ 怎樣用php做一個網站的登錄注冊

在php文件中嵌入html代碼(包含表單,做好表單驗證),提交到一個表單處理文件(php文件),處理文件里查詢資料庫,和用戶提交的用戶名,密碼匹配,異常則登錄失敗,正常則登錄成功,跳轉頁面(重定向或轉發)。注冊同理做好html頁面,提交到注冊處理頁,先校驗資料庫是否存在用戶名,有則返回注冊頁,提示注冊失敗,無則在資料庫插入用戶注冊表單的信息。

Ⅷ 用PHP做一個登錄注冊功能,點擊注冊不能跳轉頁面

感覺你的錯誤好多啊
首先:登錄頁面的注冊按鈕你盡量別用<input type='submit' ...../>這樣的,這樣的會當成form表單的提交按鈕進行處理
其次:mysql資料庫操作是使用對象的方式,即
<?php
//----------------------------------------------
$link=mysql_connect("localhost","root","") or die("連接資料庫失敗");
// 選擇資料庫
$link->mysql_select_db("student");
// 拼裝sql語句
$sql="insert into me(name,email) values('{$_POST['name']}','{$_POST['email']}')";
// 判斷執行是否成功
if (!$link->mysql_query($sql))
echo "添加失敗!";
else
echo "添加成功";

先就說這些吧,沒有看到你的登錄的頁面提交位置的php文件,無法再給你提建議了。望採納

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

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

Ⅹ php實現用戶注冊和登入,不用做效果求大牛指導

登陸界面 login.php
<form action="logincheck.php" method="post">
用戶名:<input type="text" name="user"/><br/>
密碼:<input type="password" name="pass"/><br/>
<input type="submit" name="sub" value="登陸"/>
<a href="register.php">注冊</a>
</form>
登陸處理界面logincheck.php
<?php
mysql_connect('localhost','root','');
mysql_select_db('test');
mysql_query("set names 'gbk'");
$nsql="select username,passwd,nick from userinfo where username = '$_POST[user]' and passwd = '$_POST[pass]'";
$result = mysql_query($nsql);
$num = mysql_num_rows($result);
if($num){
$row = mysql_fetch_array($result);
echo "歡迎您,$row[2]";

}else{
echo"<script>alert('用戶名或密碼不正確');history.go(-1);</script>";
}
?>
注冊界面register.php
<form action="regcheck.php" method="post">
用戶名:<input type="text" name="user"/><br/>
密碼:<input type="password" name="pass"/><br/>
昵稱:<input type="text" name="nick"/><br/>
<input type="submit" name="sub" value="注冊"/>
</form>
注冊處理界面regcheck.php
<?php
mysql_connect('localhost','root','');
mysql_select_db('test');
mysql_query("set names 'gbk'");
$nsql="select username from userinfo where username = '$_POST[user]'";
$result = mysql_query($nsql);
$num = mysql_num_rows($result);
if($num){
echo "<script>alert('用戶名已存在注冊失敗');history.go(-1);</script>";
}else{
$isql = "insert into userinfo values('$_POST[user]','$_POST[pass]','$_POST[nick]')";
mysql_query($isql);
echo"<script>alert('注冊成功');history.go(-1);</script>";
}
?>

閱讀全文

與php登陸注冊功能實現相關的資料

熱點內容
優信二手車解壓後過戶 瀏覽:61
Windows常用c編譯器 瀏覽:778
關於改善國家網路安全的行政命令 瀏覽:833
安卓如何下載網易荒野pc服 瀏覽:654
javainetaddress 瀏覽:104
蘋果4s固件下載完了怎麼解壓 瀏覽:1002
命令zpa 瀏覽:285
python編譯器小程序 瀏覽:944
在app上看視頻怎麼光線調暗 瀏覽:540
可以中文解壓的解壓軟體 瀏覽:591
安卓卸載組件應用怎麼安裝 瀏覽:912
使用面向對象編程的方式 瀏覽:339
程序員項目經理的年終總結範文 瀏覽:929
內衣的加密設計用來幹嘛的 瀏覽:432
淮安數據加密 瀏覽:292
魔高一丈指標源碼 瀏覽:982
松下php研究所 瀏覽:168
c回調java 瀏覽:399
夢幻端游長安地圖互通源碼 瀏覽:745
電腦本地文件如何上傳伺服器 瀏覽:312