[請益] 如何用curl 傳送post後導向
我現在要做金流介接
A.php 是form
submit後action="" 回來原頁面A.php
先存post的值到資料庫
再用curl post到test.php (使用者填信用卡資料)
$test1=$_POST['email'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://locathost/mobile/test.php");
curl_setopt($ch, CURLOPT_POST, 1);
//=====我要傳到test.php的資料======
curl_setopt($ch, CURLOPT_POSTFIELDS, "email=$test1");
//=================================
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_exec ($ch);
curl_close ($ch);
header('Location:test.php');
為什麼這樣寫完參數會帶不過去呢??
有請板上大哥解決
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 1.34.148.102
→
07/30 15:39, , 1F
07/30 15:39, 1F
→
07/30 15:40, , 2F
07/30 15:40, 2F
簡單說 A.php要用curl傳post給test.php
但是要傳完自動轉址 轉去後剛好接收到post顯示在信用卡資料填寫頁面
※ 編輯: sing10407 來自: 1.34.148.102 (07/30 15:48)
→
07/30 16:20, , 3F
07/30 16:20, 3F
→
07/30 16:21, , 4F
07/30 16:21, 4F
→
07/30 16:22, , 5F
07/30 16:22, 5F
上面全部都是A的CODE
A是form
POST給自己(A.php),然後先存進資料庫後在用curl post給test.php
test.php用$_POST接收顯示購物資訊在頁面上(test.php)
※ 編輯: sing10407 來自: 1.34.148.102 (07/30 16:34)
→
07/30 18:31, , 6F
07/30 18:31, 6F
就是我要讓使用者在A.php寫完個人資料後按送出到test.php
然後test.php顯示他剛剛選的產品(用$_POST接收)以及價格
test.php純粹就$_POST收參數
※ 編輯: sing10407 來自: 1.34.148.102 (07/30 18:43)
→
07/30 19:03, , 7F
07/30 19:03, 7F
→
07/30 19:04, , 8F
07/30 19:04, 8F
不Header的話有什麼方法可以導向又傳送參數呢? 有請
各位大大解答
※ 編輯: sing10407 來自: 114.36.252.92 (07/30 20:58)
→
07/30 21:01, , 9F
07/30 21:01, 9F
→
07/30 21:01, , 10F
07/30 21:01, 10F
我對PHP滿了解了
只是說金流介接是要送參數給金流公司金流的系統 所以只能送參數(post)到對方的網站
(就是這裡的test.php) 然而要選產品我還想帶不同的產品名稱+對應價格 所以才來找
cURL看看能不能解
感謝大大熱心回答
※ 編輯: sing10407 來自: 114.36.252.92 (07/30 21:20)
→
07/30 22:15, , 11F
07/30 22:15, 11F
→
07/30 22:16, , 12F
07/30 22:16, 12F
→
07/30 22:16, , 13F
07/30 22:16, 13F
→
07/30 22:17, , 14F
07/30 22:17, 14F
非常感謝kerash大大 我去試試看!
※ 編輯: sing10407 來自: 114.36.252.92 (07/30 23:13)
我發現這樣就可以做很多事了~
<body onload="document.aForm.submit()">
<form method="post" action="test.php" name="aForm">
廠商代碼: <input type="hidden" name="xxx" value="xxx"/>
</form>
</body>
※ 編輯: sing10407 來自: 114.36.252.92 (07/30 23:35)
→
07/31 09:13, , 15F
07/31 09:13, 15F
→
07/31 09:14, , 16F
07/31 09:14, 16F
好~下次我盡量描述清楚一點 感謝你!
※ 編輯: sing10407 來自: 1.34.148.102 (07/31 13:01)
PHP 近期熱門文章
PTT數位生活區 即時熱門文章