本文目錄一覽:
求一個簡單的PHP註冊,登陸代碼
我幫你找了個小程序
程序介紹:
1、共4個頁面,conn.php連接資料庫、img.php圖片驗證碼、index.php登錄頁面、register.php註冊頁面
2、註冊頁面全是用js來驗證的,所以不太完善,後續會改進
3、還沒有學習ajax,所以圖片沒法點擊刷新。原諒我吧
4、每段代碼都含有詳細注釋,方便交流學習
程序使用:
1、下載源碼上傳到你網站某個目錄
2、打開你的資料庫,在某個表中執行readme.txt中的SQL語句創建欄位用來存放用戶數據
3、修改conn.php填寫對應的資料庫地址、用戶名、密碼、數據表
4、確保上述操作無誤後,打卡URL地址進行測試
源碼git地址
使用php實現用戶註冊和登錄功能製作 !急求大神幫助!
1、需要建立一個數據表test
id int(10) primary key not null increment
name char(4) not null
pass char(10) not null
age int(2)
city char(5)
2、html頁面自己寫,用表單post傳參
3、.php頁面,處理接收到的參數,於資料庫裡面的用戶名和密碼比對,若果正確,用Js框,輸出歡迎頁面,如果不多返回到登陸頁面
這裡告訴你一個小技巧,很多時候我們都是拿用戶名和密碼一起比對,如果都正確則跳轉。這個地方其實我們需要防止sql注入攻擊,我們可以寫兩條語句,當用戶名正確,我們才執行下一條密碼比對語句,這樣可以有效防止sql的注入攻擊。
PHP怎麼實現登錄和註冊?
?php
if($_GET[‘user’] == ‘admin’ $_GET[‘pwd’] == ‘123’)
echo ‘登陸成功’;
?
form action=”” method=”get”/
table border=”0″ cellspacing=”0″ cellpadding=”0″
tr
td class=”fieldKey” width=”30%”用戶名:/td
td class=”fieldValue” width=”100%”input type=”text” name=”user” //td
/tr
trtd height=”10″/td/tr
tr
td class=”fieldKey”密碼:/td
td class=”fieldValue”input type=”password” name=”pwd” //td
/tr
/table
input type=”submit” value=”登陸”/
/form
寫了一個超級簡單的,
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”scriptalert(‘用戶名或密碼不正確’);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 “scriptalert(‘用戶名已存在註冊失敗’);history.go(-1);/script”;
}else{
$isql = “insert into userinfo values(‘$_POST[user]’,’$_POST[pass]’,’$_POST[nick]’)”;
mysql_query($isql);
echo”scriptalert(‘註冊成功’);history.go(-1);/script”;
}
?
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/303167.html