PHP在重新加载时保存表单数据
所以我得到了这个表格:PHP在重新加载时保存表单数据,php,html,Php,Html,所以我得到了这个表格: <form action="send.php" method="post"> Dogecoin-address: <input type="text" name="address"/><br> <input type="submit" name="Submit" value="Submit"> </form> <?php // starting the session session_start();
<form action="send.php" method="post">
Dogecoin-address: <input type="text" name="address"/><br>
<input type="submit" name="Submit" value="Submit">
</form>
<?php
// starting the session
session_start();
if (isset($_POST['address'])) {
$_SESSION['address'] = $_POST['Submit'];
}
?>
当用户提交他的“地址”时,我希望他的“地址”在刷新时保留/保存在第二个代码上!
如何通过使用$\u会话?或使用cookies?或任何其他方式实现这一点?
我是php新手,不知道如何使用它将您的
$\u POST
值更改为address而不是Submit。这样,您的地址存储在$\u会话['address']
变量中
您可以使用$\u会话['address']
访问该地址
$url = 'https://faucethub.io/api/v1/send?
api_key=4b21af7e916403216ffb11e523f912bc¤cy=DOGE&amount=1&to='.
$_POST['address'];
$data = array('key1' => 'value1', 'key2' => 'value2');
// use key 'http' even if you send the request to https://...
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data)
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
if ($result === FALSE) { /* Handle error */ }
var_dump($result);
?>