【问题标题】:Need help to use the following line of code to do a post method in html需要帮助使用下面这行代码在html中做一个post方法
【发布时间】:2020-02-14 21:01:39
【问题描述】:

我的值如下,我需要值来做post方法。我尝试了以下方法,但 post 方法不起作用。

              <input type="hidden" name="return_url"    value="<?php echo URLROOT; ?>/shop/payment" > 

【问题讨论】:

  • 该输入本身与请求类型没有任何关系。表单上的 method 或 ajax 请求控制它。
  • 值本身不做“post”方法....这是什么问题?

标签: php jquery html forms hyperlink


【解决方案1】:
echo '<form method="post" name="myform" action="script to check and manipulate your posts">
<input type="hidden" name="return_url" value="'.URLROOT.'/shop/payment" >
</form>';

如果您提交此表单,您将在 POST 中获得 return_url,但您需要编写一个脚本来重定向到 return_url 中给出的 url

【讨论】:

  • 我希望你在“action”属性中给出了正确的地址......并在那里完成了工作:) 你能从你的代码中粘贴更多的东西吗?一排是不够的。
【解决方案2】:

假设您有 2 个文件:

--------- form_file.php

<!DOCTYPE html>
<html>
 <body>
   <form method='post' name='myform' action='post_read.php'>
      <input type='text' name='return_url' value='blablabla.php'>
      <input type='submit' name='submit_btn' value='SUBMIT THIS FORM'>
   </form>
 </body>
</html>

--------- post_read.php

<?php
echo "POST VARIABLE: ".$_POST['return_url'];
?>

所以 form_file.php 会将 POST 变量发送到 post_read.php 文件。当然如果两个文件都在同一个目录下,否则在form_file.php中form标签的“action”属性中给form_read.php正确的地址

在我的示例中,return_url 输入字段是类型 TEXT,以显示发送到 post_read.php 文件的值,但您可以在 post_read.php 中将类型更改为隐藏,结果相同

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-09-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-21
    • 2016-07-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多