Javascript 使用自动提交的入账价值为';行不通

Javascript 使用自动提交的入账价值为';行不通,javascript,php,Javascript,Php,我有一个来自另一个页面的post值,并发布到index2.php。我想使用自动提交脚本再次将该值发布到autosubmit.php。但为什么不起作用呢 这是我的密码 index2.php <?php $mysqli = new mysqli("localhost", "root", "", "app"); if (isset($_POST['submit'])) { $drop=$_POST['drop']; $tier_two=$_POST['tier_two']; echo' <

我有一个来自另一个页面的post值,并发布到index2.php。我想使用自动提交脚本再次将该值发布到autosubmit.php。但为什么不起作用呢

这是我的密码

index2.php

<?php
$mysqli = new mysqli("localhost", "root", "", "app");
if (isset($_POST['submit'])) {
$drop=$_POST['drop'];
$tier_two=$_POST['tier_two'];

echo'
<form method="post" action="autosubmitform.php" id="dateForm" name="dateForm">
<input name="drop" type="" value="'.$drop.'" style="background-color:blue;"><input name="tier_two" type="" value="'.$tier_two.'">
<input type="submit" name="editsubmit">
</form>';

echo'<script type="text/javascript">
    document.getElementById("dateForm").submit(); // SUBMIT FORM
</script>';

}
?>

autosubmitform.php

<?php
$mysqli = new mysqli("localhost", "root", "", "app");
if (isset($_POST['editsubmit'])) {
$drop=$_POST['drop'];
$tier_two=$_POST['tier_two'];

echo $drop; echo $tier_two;
}
echo'
<input name="drop" type="" value="'.$drop.'" style="background-color:red;"><input name="tier_two" type="" value="'.$tier_two.'">
<input type="submit" name="editsubmit">';
?>

使用此脚本

window.onload = function(){
  document.forms['dateForm'].submit()

}
如下

echo"<script type="text/javascript">
    window.onload = function(){
      document.forms['dateForm'].submit()

    }
</script>";
echo”
window.onload=函数(){
document.forms['dateForm'].submit()
}
";

我讨厌不能发表评论。不过,唯一的问题是,有些人可能会在中途被抓住

若有人关闭了javascript,那个么他们就会被原始数据困在这个页面上。你还有别的办法写这个吗

您也可以只在url中传递值(GET而不是POST)并对需要加密的值进行编码

代码中的更改

   /*
    if you submit your form through javascript your button value is not submited
    so you have to click that by javascript to submit it value 
    */

 <script type="text/javascript">

   document.getElementsByName("editsubmit")[0].click(); // SUBMIT FORM
 </script>
上述PHP代码的替代解决方案

$drop = ''; 
$tier_two = ''; 
if (isset($_POST['editsubmit'])) {
    $drop=$_POST['drop'];
    $tier_two=$_POST['tier_two'];

    echo $drop; 
    echo $tier_two;

}
echo'
    <input name="drop" type="text" value="'.$drop.'" style="background-color:red;"><input name="tier_two" type="text" value="'.$tier_two.'">
    <input type="submit" name="editsubmit">';
$drop='';
$tier_two='';
如果(isset($_POST['editsubmit'])){
$drop=$_POST['drop'];
$tier_two=$tier_POST['tier_two'];
美元下跌;
echo$tier_2;
}
回声'
';

是提交不起作用还是提交但不发送数据????@rajeshkakawat不发送数据您是否检查了您的post值,var_dump($_post['drop'])查看您的内容get@rajeshkakawat这是正确的post值。但为什么我试图回应那个帖子值,但什么也没出现?@rajeshkakawatstring(10)“component1”。Component1是我的$drop value也没有在autosubmit.php中接收post值使用print\r($\u post)在autosubmit.php中打印您的post变量;再给我看一个你的类型属性在输入中是空的,填充它并尝试什么是autosubmit的输出!我使用这个技巧是因为我在使用php会话时遇到了很大的问题。
$drop = ''; 
$tier_two = ''; 
if (isset($_POST['editsubmit'])) {
    $drop=$_POST['drop'];
    $tier_two=$_POST['tier_two'];

    echo $drop; 
    echo $tier_two;

}
echo'
    <input name="drop" type="text" value="'.$drop.'" style="background-color:red;"><input name="tier_two" type="text" value="'.$tier_two.'">
    <input type="submit" name="editsubmit">';