Javascript不提交表单TRUE

Javascript不提交表单TRUE,javascript,php,html,Javascript,Php,Html,我已经试了好几个小时了,但都没法用 请执行以下操作以解决您的问题: 在表单中添加method='post' 如果要检查$\u POST['submit']的值,需要将按钮命名为“submit” 您不能使用echo和header(“”),它将设置“header ready sent exception” header('Location:some text')没有任何意义,header('Location:file.html')是正确的语法 完整代码: if(!$_POST['submit'])

我已经试了好几个小时了,但都没法用

请执行以下操作以解决您的问题:

  • 在表单中添加
    method='post'
  • 如果要检查
    $\u POST['submit']
    的值,需要将按钮命名为“submit”
  • 您不能使用echo和header(“”),它将设置“header ready sent exception”
  • header('Location:some text')没有任何意义,header('Location:file.html')是正确的语法
  • 完整代码:

    if(!$_POST['submit']) {
    echo "please fill out the form";
    header ('Location: please fill out the form 1');}
    
    
    函数myFunction(){
    document.getElementById(“form1”).submit();
    document.getElementById(“form2”).submit();
    }
    名称
    赫姆西达
    PHP:

    if(空($_POST)| |!$_POST['submit'])){
    echo“请填写表格”;
    //回显后无法设置标题
    //header('Location:请填写表格1');//改用header('Location:error.html')。
    //或者输出Javascript重定向回显“window.location='error.html';”;
    }
    

    希望这有帮助

    一,。内联JavaScript很糟糕。2.你的函数没有返回任何东西。还有,为什么javascript要提交呢?合并成一种形式会更容易。另外,如果您确实想使用javascript提交,请使用e.preventDefault;我在两个表单之间有一个搜索表单,这就是为什么我得到了两个表单,但是如果我在这两个表单上都放上相同的ID,它会工作吗?我得到“TypeError:Property'submit'of object#不是一个函数”并且对位置名感到抱歉,我用它来知道ID,我浏览了所有的php文件。为什么你甚至用myFunction()来提交表单?当我只使用submit时只需更改,只需提交其中一个表单。
    if(!$_POST['submit']) {
    echo "please fill out the form";
    header ('Location: please fill out the form 1');}
    
    <script type="text/javascript">
    function myFunction(){
      document.getElementById("form1").submit();
      document.getElementById("form2").submit();
    }
    </script>
    
    <form id="form1" action="php/create.php" method="post">
    Name </br><input  type="text" name="inputName" value="" id=""> </input>
    Hemsida </br><input  type="text" name="inputPage" value="http://" id=""> </input>
    
    <input type="button" onclick="return myFunction()" value="Submit" name="submit"/>
    
    </form>
    <form id="form2" action="php/createhemerb.php" method="post">
    <input type="text" name="inputFon" value="" id="fnid" hidden/>
    <input  type="text" name="inputJob" value="" id="fnid" hidden/>
    </form>
    
    if(empty($_POST) || !$_POST['submit']) {
    echo "please fill out the form";
    //you can't set the header after echoing
     //header ('Location: please fill out the form 1');//use header('Location: error.html') instead.
    //or output a Javascript redirect echo "<script>window.location = 'error.html';</script>";
    }