方法1:

成都網(wǎng)站設(shè)計、成都網(wǎng)站制作服務(wù)團隊是一支充滿著熱情的團隊,執(zhí)著、敏銳、追求更好,是創(chuàng)新互聯(lián)的標準與要求,同時竭誠為客戶提供服務(wù)是我們的理念。創(chuàng)新互聯(lián)公司把每個網(wǎng)站當做一個產(chǎn)品來開發(fā),精雕細琢,追求一名工匠心中的細致,我們更用心!
input type="button" value="f1" onclick="f1()"
script
//方法1
function f1(){
var type = 'aaa';
window.location.href='1.php?type=' + type;
}
/script
1.php 中:
$type = $_GET['type'];
echo $type;
方法2:
script src="jquery-1.10.2.min.js"/script
script
$(document).ready(function(){
var type ='aaa';
$("button").click(function(){
$.post("4-ajax.php",{
type: type,
},
function(data,status){
alert("數(shù)據(jù):" + data + "\n狀態(tài):" + status);
});
});
});
/script
button向頁面發(fā)送 HTTP POST 請求,并獲得返回的結(jié)果/button
4-ajax.php中:
$type = $_POST["type"];
echo $type;
通過session來儲存
?php
session_start();
$_SESSION['username'] = "userName";
?
在其它頁面直接取出就行了
?
session_start();
echo?$_SESSION['username'];
?
通過url傳向其它頁面?zhèn)鬟f參數(shù)
other.php?user=xxx
?或在php重定向到其它頁面時
$username = "xxx";
$home_url = 'logIn.php?user='.$username;
header('Location:'.$home_url);
其它頁面用$_GET["user"]來接收
3.通過表單向其它頁面?zhèn)魉蛥?shù)
其它頁面用$_POST["user"]來接收
通過session來儲存
?php
session_start();
$_SESSION['username'] = "userName";
?
在其它頁面直接取出就行了
?
session_start();
echo?$_SESSION['username'];
?
通過url傳向其它頁面?zhèn)鬟f參數(shù)
other.php?user=xxx
或在php重定向到其它頁面時
$username = "xxx";
$home_url = 'logIn.php?user='.$username;
header('Location:'.$home_url);
其它頁面用$_GET["user"]來接收
3.通過表單向其它頁面?zhèn)魉蛥?shù)
其它頁面用$_POST["user"]來接收
文章名稱:怎么向php文件傳數(shù)據(jù),怎么向php文件傳數(shù)據(jù)
轉(zhuǎn)載注明:http://chinadenli.net/article39/dsegjph.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供自適應(yīng)網(wǎng)站、用戶體驗、ChatGPT、網(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)