欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

php連接數(shù)據(jù)庫注冊用戶 php登錄注冊連接數(shù)據(jù)庫

PHP注冊用戶連接到MDB數(shù)據(jù)庫

個人猜測:去學(xué)PHP調(diào)用WORD的方法,然后用PHP調(diào)用MS的ACCESS來訪問~

目前創(chuàng)新互聯(lián)已為近1000家的企業(yè)提供了網(wǎng)站建設(shè)、域名、網(wǎng)頁空間、綿陽服務(wù)器托管、企業(yè)網(wǎng)站設(shè)計、德興網(wǎng)站維護等服務(wù),公司將堅持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。

PHP注冊不了,可以連接數(shù)據(jù)庫,sql放入數(shù)據(jù)庫正常使用,就是無法在頁面注冊!

你有一處需要優(yōu)化

2處需要修改

$info=mysql_fetch_array($sql);

if($info==true)

改成

if ( mysql_num_rows($info) )

c錯誤的地方是:你把session的值全部設(shè)置成了null值,其實就是空值!

例外,數(shù)據(jù)庫顯示不了,只能說明寫入數(shù)據(jù)庫失敗,壓根就沒有寫入數(shù)據(jù)庫,你的注冊根本就沒有成功

mysql_query("insert into user (name,pwd,dongjie,email,truename,sfzh,tel,qq,ip,tishi,huida,dizhi,youbian,regtime,lastlogintime,logincishu,pwd1) values ('$name','$pwd','$dongjie','$email','$truename','$sfzh','$tel','$qq','$ip','$tishi','$huida','$dizhi','$youbian','$regtime','$lastlogintime','$logincishu','$pwd1')",$conn);

改成

mysql_query("insert into user (name,pwd,dongjie,email,truename,sfzh,tel,qq,ip,tishi,huida,dizhi,youbian,regtime,lastlogintime,logincishu,pwd1) values ('$name','$pwd','$dongjie','$email','$truename','$sfzh','$tel','$qq','$ip','$tishi','$huida','$dizhi','$youbian','$regtime','$lastlogintime','$logincishu','$pwd1')",$conn) or die(mysql_error());

然后運行一下,看有什么錯誤提示

php登錄頁面完整代碼連接數(shù)據(jù)庫

創(chuàng)建conn.php,連接數(shù)據(jù)庫。

$dns = 'mysql:host=127.0.0.1;dbname=test';

$username = 'root';

$password = 'root';

// 1.連接數(shù)據(jù)庫,創(chuàng)建PDO對象

$pdo = new PDO($dns,$username,$password);

創(chuàng)建login.html,登陸頁面。

用戶名

密 碼

創(chuàng)建login.php,驗證賬號密碼。

header("Content-Type: text/html; charset=utf8");

if(!isset($_POST["submit"])){

exit("錯誤執(zhí)行");

}//檢測是否有submit操作

include('conn.php');//鏈接數(shù)據(jù)庫

$name = $_POST['name'];//post獲得用戶名表單值

$pwd = sha1($_POST['password']);//post獲得用戶密碼單值

if ($name $pwd){//如果用戶名和密碼都不為空

$sql = "select * from user where username = '$name' and password='$pwd'";//檢測數(shù)據(jù)庫是否有對應(yīng)的username和password的sql

$stmt = $pdo-prepare($sql);

$stmt-execute();

if($stmt-fetch(PDO::FETCH_BOUND)){//0 false 1 true

header("refresh:0;url=welcome.html");//如果成功跳轉(zhuǎn)至welcome.html頁面

exit;

}else{

echo "用戶名或密碼錯誤";

echo "

setTimeout(function(){window.location.href='login.html';},1000);

";//如果錯誤使用js 1秒后跳轉(zhuǎn)到登錄頁面重試;

}

}else{//如果用戶名或密碼有空

echo "表單填寫不完整";

echo "

setTimeout(function(){window.location.href='login.html';},1000);

";

//如果錯誤使用js 1秒后跳轉(zhuǎn)到登錄頁面重試;

}

$pdo = null;

創(chuàng)建signup.html,注冊頁面

用戶名:

密 碼:

創(chuàng)建signup.php

header("Content-Type: text/html; charset=utf8");

if(!isset($_POST['submit'])){

exit("錯誤執(zhí)行");

}//判斷是否有submit操作

$name=$_POST['name'];//post獲取表單里的name

$pwd = sha1($_POST['password']);//post獲取表單里的password

include('conn.php');//鏈接數(shù)據(jù)庫

$sql="insert into user(id,username,password) values (null,'$name','$pwd')";//向數(shù)據(jù)庫插入表單傳來的值的sql

$stmt = $pdo-prepare($sql);

$stmt-execute();

$stmt-fetch(PDO::FETCH_BOUND);

if (!$stmt){

die('Error: ' . $stmt-getMessage());//如果sql執(zhí)行失敗輸出錯誤

}else{

echo "注冊成功";//成功輸出注冊成功

}

$pdo = null;//關(guān)閉數(shù)據(jù)庫

php+mysql怎么做登錄注冊

首先得到提交的數(shù)據(jù)

鏈接數(shù)據(jù)庫,查詢數(shù)據(jù)庫,查詢username 和pwd

提交的username 和 pwd? 跟數(shù)據(jù)庫查詢的username 和pwd做對比,

都相等那就是登陸成功

?php

mysql_connect('localhost','root','123');

mysql_select_db('lx');

mysql_query("SET?CHARACTER?SET?utf8");

mysql_query("SET?NAMES?utf8");

//數(shù)據(jù)庫lx?表user??字段id?username??pwd

//用md5加密,可以自己試試????

if(isset($_POST['user'])$_POST['tijiao']?==?'success'){

$query?=?mysql_query("select?pwd?from?user?where?username?=?'".$_POST['user']."'");

$num?=?mysql_num_rows($query);

if($num??0?){

while($info?=?mysql_fetch_array($query)){

if($info['pwd']?==?md5($_POST['pwd'])){

echo?'登陸成功';

}else{

echo?'登陸失敗';????

}

}

}else{

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="hidden"?name="tijiao"?value="success"?/

input?type="submit"?value="登陸"/

/form

標題名稱:php連接數(shù)據(jù)庫注冊用戶 php登錄注冊連接數(shù)據(jù)庫
文章URL:http://chinadenli.net/article24/dojgeje.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供小程序開發(fā)企業(yè)網(wǎng)站制作定制開發(fā)搜索引擎優(yōu)化移動網(wǎng)站建設(shè)網(wǎng)站營銷

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)公司