建立index.php

創(chuàng)新互聯(lián)專注于白云鄂企業(yè)網(wǎng)站建設(shè),響應(yīng)式網(wǎng)站建設(shè),商城網(wǎng)站建設(shè)。白云鄂網(wǎng)站建設(shè)公司,為白云鄂等地區(qū)提供建站服務(wù)。全流程定制網(wǎng)站制作,專業(yè)設(shè)計,全程項目跟蹤,創(chuàng)新互聯(lián)專業(yè)和態(tài)度為您提供的服務(wù)
輸入:
form action='reg.php' method='method'
用戶名:input type='text' name='uname' /br
密碼:input type='password' name='upassword' /br
input type='注冊' value='submit' /
/form
保存退出
在相同目錄下建立regist.php
輸入:
?php
$username=$_POST[uname]; //通過POST方法獲得提交數(shù)據(jù),uname對應(yīng)index.php中的uname;upassword一樣
$userpassword=$_POST[upassword];
mysql_connect('localhost','root','數(shù)據(jù)庫密碼); //鏈接數(shù)據(jù)庫
mysql_select_db('數(shù)據(jù)庫名'); //選擇數(shù)據(jù)庫
$sql = "insert into user(uname,upassword) values"('$username',$userpassword); //插入數(shù)據(jù)的SQL字符串
if(mysql_query($sql)){ //mysql_query($sql)執(zhí)行插入語句,if為判斷是否插入成功
}else{
echo '注冊失敗';
}
?
首先得到提交的數(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
傳統(tǒng)方法是用 form標簽 將輸入的數(shù)據(jù) 提交到后臺的php, 由php獲得數(shù)據(jù)后寫入數(shù)據(jù)庫, 下面SubMsg.php 就是用來處理的后臺
form name="MsgForm" method="post" action="SubMsg.php" onsubmit="return CheckForm();"label for='jqshul'機器數(shù)量/labelinput name="jqshul" type="text" class="InputBorder" id="jqshul" size="66" input type="submit" name="Submit" value="預(yù)定" /form
后臺 SubMsg.php
? if (!isset($jqshul)){ echo "機器數(shù)量不存在," return;} echo $jqshul;//這個變量就是從前臺接收的機器數(shù)量. 字段的name 是什么就寫什么// 如何寫入數(shù)據(jù)庫, 要看用什么數(shù)據(jù)庫了 要配置數(shù)據(jù)庫不是一兩句能說清的了//大致流程 是配置數(shù)據(jù)庫 打開數(shù)據(jù)連接 根據(jù)變量生成SQL語句 執(zhí)行語句?
你是哪部分不會,數(shù)據(jù)庫連接正常不寫好了沒?數(shù)據(jù)庫表設(shè)計好了沒?注冊登錄頁面前端寫好了沒?用session就可以實現(xiàn)登錄了,然后就是你其他頁面了,沒開發(fā)好,可以代開發(fā)
先會寫html的表單
然后會寫php接收表單。
然后會連接數(shù)據(jù)庫,查找數(shù)據(jù)庫對應(yīng)字段。
判斷下
匹配跳轉(zhuǎn)到相應(yīng)頁面,或者記錄session等。
注冊頁面:reg.html
form action="reg.php" method="POST"
table
trtd用戶名:/tdtdinput type="username" size="20"/td/tr
trtd密碼:/tdtdinput type="userpass" size="20"/td/tr
trtd確認密碼:/tdtdinput type="ruserpass" size="20"/td/tr
trtd郵箱:/tdtdinput type="email" size="50"/td/tr
trtd電話:/tdtdinput type="telphone" size="20"/td/tr
trtdinput type="Submit" value="注冊"/td/tr
/table
/form
接收頁面:reg.php
%php
$db = mysql_connect("localhost", "root", "12345");
mysql_select_db("dataname", $db);
mysql_query("insert into tablename(username, userpass, email, telphone) values('$_POST[username]', '$_POST[userpass]', '$_POST[email]', '$_POST[telphone]')");
echo "注冊成功";
%
網(wǎng)站名稱:php登陸注冊實現(xiàn)數(shù)據(jù)庫 用php實現(xiàn)注冊登錄
瀏覽路徑:http://www.chinadenli.net/article18/doddsdp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信小程序、品牌網(wǎng)站設(shè)計、動態(tài)網(wǎng)站、小程序開發(fā)、標簽優(yōu)化、ChatGPT
聲明:本網(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)