Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP在重新加载时保存表单数据_Php_Html - Fatal编程技术网

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&currency=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);
?>