我如何获取输入到表单中的值,重定向到可以检索该变量的 php 页面


How do I take a value entered into a form, redirect to a page a php page that can retrieve that variable?

>我需要连接两个部分

1) 收集网站网址的简单 HTML 表单

2) 接收从表单输入的 url 的 PHP 脚本。

我已经完成了 PHP 脚本,但只有当我在 PHP 脚本中对 url 值进行硬编码时,它才有效。 我不明白如何将 url 值从 html 表单传输到 PHP 脚本。

这是形式:

<form id="dm" class="api"  method="post" action="apigenerate.php">
  <input id="element_1" name="element_1" class="element text medium" type="text" maxlength="255" value=""/> 
  <input type="hidden" name="form_id" value="710370" />
  <input class="button_text" type="submit" name="submit" value="Submit" />
</form> 

这是 API 脚本,第 6 行是输入值需要去的地方

<?php
$data = '
{   
"site_data":
{                       
" the form input goes here "
}
}
';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.servername.com');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, "username:Ypassword");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                             

看看你到目前为止做了什么可能会有所帮助,但传统上你会做这样的事情:

.HTML

<form action=myscript.php method=POST>
   <input type=text name=websiteUrl />
</form>

.PHP

<?php
   $url = $_POST['websiteUrl'];
?>