注冊頁面:reg.html
成都創(chuàng)新互聯(lián)于2013年成立,先為寧明等服務(wù)建站,寧明等地企業(yè),進行企業(yè)商務(wù)咨詢服務(wù)。為寧明企業(yè)網(wǎng)站制作PC+手機+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問題。
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 "注冊成功";
%
首先可以采用的是Jquery的Ajax技術(shù)進行操作。
思路是這樣的,首先現(xiàn)在前端判斷JS并提交給后臺,代碼如下:
$(function(){
$.ajax({
type:post,
dataType:json,
url:?save.php,
data:$("input[name=x]").val(),
success:function(data){
}
});
});
這樣后端接收到Ajax請求后進行連接數(shù)據(jù)庫并且插入數(shù)據(jù)
其它操作類似進行操作即可。
首先你要建立一個表,例如是注冊的用戶表user
,里面的結(jié)構(gòu)有字段
id,
name,nickname,email等。
然后在你的表單處form
action="a.php"
method="post"
name="regform"(如果有圖片上傳,還要加上enctype="multipart/form-data")
,那么點擊表單提交按紐后,此表單將會交給處理頁a.php來作處理。
如果簡單點,你就直接可以將表單傳遞過來的數(shù)據(jù)$_POST,直接用sql插入語句,insert
into來插入到數(shù)據(jù)庫,表user中。例如insert
into
user
set
name='".$_POST['name']."'.............................
建立index.php
輸入:
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 '注冊失敗';
}
?
傳統(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í)行語句?
本文題目:php表單注冊存入數(shù)據(jù)庫 php數(shù)據(jù)庫登錄注冊頁面
本文網(wǎng)址:http://sd-ha.com/article42/hjdiec.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站策劃、用戶體驗、軟件開發(fā)、品牌網(wǎng)站設(shè)計、網(wǎng)站維護、App開發(fā)
聲明:本網(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)