form表單demo:task.html
沙洋ssl適用于網(wǎng)站、小程序/APP、API接口等需要進行數(shù)據(jù)傳輸應(yīng)用場景,ssl證書未來市場廣闊!成為創(chuàng)新互聯(lián)建站的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18982081108(備注:SSL證書合作)期待與您的合作!
fieldset id="setFiled"
legend發(fā)布任務(wù)/legend
form action="registr.php" method="post" id="steForm"
label任務(wù)類型:/labelbr
input type="text" name="type"? id="taskType" placeholder="請選擇任務(wù)類型"/br
label酬nbsp;nbsp;金:/labelbr
input type="number" name="money" id="forMoney" min="1" max="1000"/label元/labelbr
label截止時間:/labelbr
input type="datetime" name="time" id="timeSubmit"/span data-year="" data-month="" data-date="" id="showDate"/spanbr
label詳細(xì)描述:/labelbr
textarea maxlength="512" name="textAray" id="msgArea"/textareabr
input type="submit" name="subMit" id="forSub" value="點擊發(fā)布" /
/form
擴展資料
php接收POST數(shù)據(jù)的三種方式
1、$_POST 方式接受數(shù)據(jù)
$_POST 方式是由通過HTTP的POST方法傳遞過來的數(shù)據(jù)組成的數(shù)組,是一個自動全局變量。
注:只能接收Content-Type:application/x-www-form-urlencode提交的數(shù)據(jù)。也就是只能接收表單過來的數(shù)據(jù)。
2、GLOBLES[‘HTTP_RAW_POST_DATA’]
如果訪問原始POST數(shù)據(jù)不是php能夠識別的文檔類型,比如:text/xml 或者soap等等,可以用$GLOBLES[‘HTTP_RAW_POST_DATA’]來接收,$HTTP_RAW_POST_DATA變量包含有原始POST數(shù)據(jù)。此變量僅在碰到未識別的MIME數(shù)據(jù)時產(chǎn)生。
注:$HTTP_RAW_POST_DATA對于enctype=”multipart/form-data”表單數(shù)據(jù)不可用,也就是說使用$HTTP_RAW_POST_DATA無法接受網(wǎng)頁表單post過來的數(shù)據(jù)。
3、file_get_contents(“php://input”);
如果訪問原始POST數(shù)據(jù),更好的方法是使用file_get_content(“php://input”);對于未指定Content-Type的POST數(shù)據(jù),可以使用該方法讀取POST原始數(shù)據(jù),包括二進制流也可以和$HTTP_RAW_POST_DATA比起來。它帶來的生存眼里更小,并且不需要任何特殊的php.ini設(shè)置。
注:php://input不能用于 enctype=”multipart/form-data”
例如:$postStr = file_get_contents("php://input"); //獲取POST數(shù)據(jù)
PHP向MySQL數(shù)據(jù)庫中寫入數(shù)據(jù)有三個步驟:
1,PHP和MySQL建立連接關(guān)系
2,打開MySQL數(shù)據(jù)庫
3,接受頁面數(shù)據(jù),PHP錄入到指定的表中
1、2兩步可直接使用一個數(shù)據(jù)庫鏈接文件即可:conn.php
代碼如下
?php
mysql_connect("localhost","root","");//連接MySQL
mysql_select_db("hello");//選擇數(shù)據(jù)庫
?
當(dāng)然,前提是已經(jīng)安裝WEB服務(wù)器、PHP和MySQL,并且建立MySQL表“cnbruce”
mysql_connect()中三個參數(shù)分別為MySQL地址、MySQL用戶名和MySQL密碼
然后就是通過WEB頁面?zhèn)鬟f數(shù)據(jù),讓PHP通過SQL語句將數(shù)據(jù)寫入MySQL數(shù)據(jù)庫指定的表中,比如新建文件 post.php
代碼如下
?php
require_once("conn.php");//引用數(shù)據(jù)庫鏈接文件
$uname = $_GET['n'];//GET方法為URL參數(shù)傳遞
$psw = $_GET['p'];
$psw=md5($psw);//直接使用MD5加密
$sql = "insert into members(username,password) values ('$uname','$psw')";
mysql_query($sql);//借SQL語句插入數(shù)據(jù)
mysql_close();//關(guān)閉MySQL連接
echo "成功錄入數(shù)據(jù)";
?
測試頁面: ;p=i0514
即可向MySQL數(shù)據(jù)庫hello的members表中插入新的數(shù)據(jù)“cnbruce”到username字段、“i0514”到password字段
補充:讀取表
讀取表中的內(nèi)容,這里我們用while,可以根據(jù)具體情況,用for 或其他的.
代碼如下
while($row = mysql_fetch_array($result))
{
echo "div style="height:24px; line-height:24px; font-weight:bold;""; //排版代碼
echo $row['Topic'] . "br/";
echo "/div"; //排版代碼
?php
//?以?MySQL?為例:
mysql_connect('127.0.0.1',?'root',?'root',?3306);??//?連接數(shù)據(jù)庫
mysql_select_db('test');???????????????????????????//?選擇數(shù)據(jù)庫
mysql_query('set?names?utf8');?????????????????????//?執(zhí)行SQL
//?插入數(shù)據(jù)語句
$sql?=?"INSERT?INTO?table?(username,?password)?VALUES?('Jack@163.com',?'123456')";
$r?=?mysql_query($sql);
if?(mysql_affected_rows())?{
echo?'新增成功';
}?else?{
echo?mysql_error();
}
網(wǎng)站欄目:php寫入數(shù)據(jù)可 php寫入文件內(nèi)容方法
轉(zhuǎn)載源于:http://jinyejixie.com/article0/dohppio.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)頁設(shè)計公司、用戶體驗、App開發(fā)、網(wǎng)站改版、網(wǎng)站維護、外貿(mào)建站
聲明:本網(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)