當前位置:首頁 » 編程語言 » php注冊登錄源碼

php注冊登錄源碼

發布時間: 2023-01-11 05:20:59

⑴ 用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 代碼 「登陸」 沒有任何反應,源代碼如下:

}elseif($action=='login'){
這句是不是應該
if($_GET['action']=='login'){
這樣寫呢?

⑶ 求php實現登錄成功後返回首頁並在原登錄處顯示用戶名的源代碼(類似於鐵血網的登錄)

<?php
session_start();//用SESSION記錄模式,並開啟。
//用戶登錄信息,並記錄
if(@$_POST['GoLog']){
$_SESSION['user']=@$_POST['login'];
}
//主頁的檢查用戶登錄與否,並顯示歡迎信息
if(@$_SESSION['user']==''){
echo"目前沒有登錄";
}else{
echo$_SESSION['user']."歡迎你的回來!";
}
?>
<formaction=''method='post'>
<inputtype='text'name='login'/>
<inputtype='submit'name='GoLog'value='登錄'/>
</form>

我只是給你寫了個原理,你可以加入更多的判斷。

⑷ 易語言+PHP+資料庫做注冊登錄程序 怎麼做,最好是有教程跟源碼

要是說教程,沒有哪個教程是指定講哪個問題的,這裡面涉及的知識,易語言操作mysql或post或網頁填表。教程都很好找。為什麼說或,因為常用大概就這三種方法。

  1. 直接操作資料庫,易語言直接鏈接網站的資料庫,可以不通過php來操作,直接把要注冊的帳號寫進資料庫,這是最直接的方法。

  2. post,首先用httpwatch或其他抓包工具,抓取注冊時的數據包,然後用易語言(精益模塊)網頁_訪問這個方法來進行自製數據包提交。來完成注冊。

  3. 網頁填表,屬於在超文本瀏覽框內打開網站注冊頁面,然後模擬手動來填寫注冊信息。

建議使用的方法是post,因為直接操作資料庫安全性不高,網頁填表每次都要打開一次注冊頁面,效率不高,建議使用post方法。post視頻教程可以找 之乎者也的post教程,關於post的教程有很多

⑸ 求一個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>

⑹ php表單注冊時數據寫入記事本,登錄時讀取記事本數據驗證登錄信息,請附上源碼。

為什麼不放入資料庫中呢?

⑺ 求份php注冊登錄需要邀請碼才能注冊的源碼,要求自己能生成邀請碼,付費也可以。

把邀請碼存在資料庫,注冊的時候查詢一下這個邀請碼存在就可以注冊,不存在就不能注冊。最好加兩個欄位一個被邀請的號碼,一個自己的邀請碼

⑻ 求一用php寫的注冊和登錄頁面代碼

reg.php文件
<?php
header("Content-type:text/html;charset=utf-8");
if($_POST){
$dsn = 'mysql:dbname=1104javab;host=127.0.0.1';
$user = 'root';
$password = '';
try{
$pdo = new pdo($dsn,$user,$password,array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\'')
);
}catch(Exception $e){
echo '錯誤'.$e->getmessage();
}
$name = $_POST['name'];
$pwd = md5($_POST['pwd']);
$sql = "insert into 表 (username,password) values ('$name','$pwd')";
$exec = $pdo->query($sql);
if($exec){
echo "<script>alert('成功');location.href='reg.html'</script>";
}else{
echo "<script>alert('失敗');location.href='reg.html'</script>";
}
}
?>
reg.html文件
<form action='reg.php' method='post'>
用戶名:<input type='text' name='name'>
密碼:<input type='password' name='pwd'>
<input type='submit' value='submit'>
</form>
login.html文件
<form action='reg.php' method='post'>
用戶名:<input type='text' name='name'>
密碼:<input type='password' name='pwd'>
<input type='submit' value='submit'>
</form>
login.php文件
header("Content-type:text/html;charset=utf-8");
if($_POST){
$dsn = 'mysql:dbname=1104javab;host=127.0.0.1';
$user = 'root';
$password = '';
try{
$pdo = new pdo($dsn,$user,$password,array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\'')
);
}catch(Exception $e){
echo '錯誤'.$e->getmessage();
}
$name = $_POST['name'];
$pwd = $_POST['pwd'];
$sql = "select user_id from 表名 where username='$name' and password='$pwd'";
$stmt = $pdo->query($sql);
$info = $stmt->fetch(PDO::FETCH_ASSOC);
if($info){
echo "登錄成功";
}else{
echo "登錄失敗";
}
}

大概這樣

⑼ 今天做了一個php簡單的注冊登錄頁面,請問一下下,登錄以後怎麼修改密碼…有這樣的簡單源代碼嗎…求

進入登陸頁面 控制器 寫一個控制器類 從頁面顯示 原生態應該是寫一個mysql語句 之後更改密碼

⑽ 怎麼給一已經寫好的PHP登錄系統在源碼里添加一個賬號密碼

添加帳號和密碼跟後台的PHP代碼沒有任何關系。
如果要添加帳號和密碼就必須要登錄Mysql資料庫, 在對應的管理員的數據表中插入username和password.
注意:
一般的password 都是用md5函數加密的。後台的資料庫的密碼也需要加密後復制到對應的密碼欄,否則依然無法登陸。
提示:
mysql資料庫操作最好用phpMyadmin文件來操作,這樣更可視話操作。更適合新手。

熱點內容
python讀取txt 發布:2025-07-13 10:56:50 瀏覽:641
c語言ftp伺服器 發布:2025-07-13 10:56:36 瀏覽:413
mdb壓縮 發布:2025-07-13 10:56:02 瀏覽:425
ftp虛擬目錄上傳文檔 發布:2025-07-13 10:51:18 瀏覽:640
香港雲伺服器建站有用嗎 發布:2025-07-13 10:46:26 瀏覽:435
安卓如何進入賞金賽 發布:2025-07-13 10:44:48 瀏覽:812
obd源碼android 發布:2025-07-13 10:43:59 瀏覽:795
編譯器錯誤cs0016 發布:2025-07-13 10:42:36 瀏覽:771
c語言二進制代碼 發布:2025-07-13 10:27:28 瀏覽:19
kc杯腳本 發布:2025-07-13 10:27:22 瀏覽:614