Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/281.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 tab div中有三个单独的表单_Php_Html - Fatal编程技术网

Php tab div中有三个单独的表单

Php tab div中有三个单独的表单,php,html,Php,Html,我在tab div中有三个报表。所有这些表单都是提交表单,数据必须保存到数据库中。所有这些表单单独工作正常,但当我在tab div中给出时,只有第一个表单工作正常,但它会影响其他两个表单的功能,并且我无法将值插入数据库。有什么问题吗在将这些表格放入选项卡之前,我需要知道。我需要尽快解决此问题。请帮助 这是我的代码:我使用include()在单击tab div时将控件传递给该特定文件。这是正确的方法吗 <html> <head> <link href="sty

我在tab div中有三个报表。所有这些表单都是提交表单,数据必须保存到数据库中。所有这些表单单独工作正常,但当我在tab div中给出时,只有第一个表单工作正常,但它会影响其他两个表单的功能,并且我无法将值插入数据库。有什么问题吗在将这些表格放入选项卡之前,我需要知道。我需要尽快解决此问题。请帮助

这是我的代码:我使用include()在单击tab div时将控件传递给该特定文件。这是正确的方法吗

<html>
<head>
    <link href="style.css" rel="stylesheet" type="text/css" />
    <link href="ex.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="tabs">
    <ul class="tab-links">
        <li class="active"><a href="#tab1"> Report1</a></li>
        <li><a href="#tab2"> Report2</a></li>
        <li><a href="#tab3">Report3</a></li>
     </ul>
      <div class="tab-content">
        <div id="tab1" class="tab active">

        <?php
        include("Report1.php");

         ?>

 </div>     
   <div id="tab2" class="tab">

        <?php
        include ("Report2.php");
         ?>


    </div>
     <div id="tab3" class="tab">
  <p>
        <?php
        include("Report3.php");
         ?>
         </p>

    </div>
     </div>
</div>  

    </body>
</html> 

以下是我的jquery:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> 
<script>
jQuery(document).ready(function() {
    jQuery('.tabs .tab-links a').on('click', function(e)  {
        var currentAttrValue = jQuery(this).attr('href');

        // Show/Hide Tabs
        jQuery('.tabs ' + currentAttrValue).show().siblings().hide();

        // Change/remove current tab to active
        jQuery(this).parent('li').addClass('active').siblings().removeClass('active');

        e.preventDefault();
    });
});
</script>

jQuery(文档).ready(函数(){
jQuery('.tabs.tab链接a')。on('click',函数(e){
var currentAttrValue=jQuery(this.attr('href');
//显示/隐藏选项卡
jQuery('.tabs'+currentAttrValue).show().hide();
//将当前选项卡更改/删除为活动选项卡
jQuery(this).parent('li').addClass('active').sides().removeClass('active');
e、 预防默认值();
});
});
这是我的PHP文件:Report1.PHP

 <?php
    include_once 'dataAccessControl.php';
    $DataAccessController = new DataAccessController();
    if(isset($_POST['report']))
     {
        $daydropdown=$_POST['daydropdown'];
        $monthdropdown=$_POST['monthdropdown'];
        $yeardropdown=$_POST['yeardropdown'];
        $dreport_place=$_POST['dreport_place'];
        $dreport_address=$_POST['dreport_address'];
        $dreport_additional=$_POST['dreport_additional'];
     }
     else 
     {
        $daydropdown="";
        $monthdropdown="";
        $yeardropdown="";
        $dreport_place ="";
        $dreport_address="";
        $dreport_additional="";
     }

    if ($_SERVER["REQUEST_METHOD"] == "POST") 
    {
        $death = $DataAccessController->death_reports($_POST['daydropdown'],$_POST['monthdropdown'],$_POST['yeardropdown'],$_POST['dreport_place'], $_POST['dreport_address'], $_POST['dreport_additional']);
        if ($death) {
              echo"<p><font  color=red  size='5pt' > Your Death Report has been Registered</font></p>";
            header("Refresh:3;url='newhome.php'");
            } 
    }
    ?>

    <html>
    <head>
    <link href="style.css" rel="stylesheet" type="text/css" />
    <title>Death Report</title>  

    <script type="text/javascript">

    var monthtext=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sept','Oct','Nov','Dec'];

    function populatedropdown(dayfield, monthfield, yearfield)
    {
       var today=new Date()
       var dayfield=document.getElementById(dayfield)
       var monthfield=document.getElementById(monthfield)
       var yearfield=document.getElementById(yearfield)
        for (var i=0; i<=31; i++)
       dayfield.options[i-1]=new Option(i, i)
       dayfield.options[today.getDate()-1]=new Option(today.getDate(), today.getDate(), true, true) //select today's day
       for (var m=0; m<12; m++)
       monthfield.options[m]=new Option(monthtext[m], monthtext[m])
       monthfield.options[today.getMonth()]=new Option(monthtext[today.getMonth()], monthtext[today.getMonth()], true, true) //select today's month
       var thisyear=1999
       for (var y=0; y<45; y++){
       yearfield.options[y]=new Option(thisyear, thisyear)
       thisyear+=1
       }
       yearfield.options[0]=new Option(today.getFullYear(), today.getFullYear(), true, true) //select today's year
    }
    </script>
    </head>

    <body >
    <div id="color" >
        <table>

                <h1 align="center"><p> Report1</h1>


        <form action="" method="POST">
            <tr><td>Date  </td><td>
                <select name="daydropdown" id="daydropdown"></select> 
                <select name="monthdropdown" id="monthdropdown"></select>
                <select name="yeardropdown" id="yeardropdown"></select>
                <script type="text/javascript">
                //populatedropdown(id_of_day_select, id_of_month_select, id_of_year_select)
                    window.onload=function()
                    {
                        populatedropdown("daydropdown", "monthdropdown", "yeardropdown")
                    }
                </script>
            </td></tr>

            <tr><td></br>  Place  </td><td></br><select name="dreport_place"id="wgtmsr">
            <option value="hospital" >Hospital</option><option value="residence">Residence</option><option value="others">Others</option></select></td></tr>

            <tr><td>Address  </td><td></br><textarea name="dreport_address" rows="5" cols="32" id="loc" value=""> </textarea></td></tr>

            <tr><td>Additional Cases if any</td><td></br> <textarea name="dreport_additional" rows="5" cols="32" id="loc" value=""> </textarea></td></tr></label></td></tr>

            <tr><td></td><td><input type="submit" name="report" value="Save" id="btnsize" /></td></tr>

        </form>
        </table></br>
    </div>


    </body>
    </html>

看看你在这里做什么:

if ($_SERVER["REQUEST_METHOD"] == "POST") 
{
    $death = $DataAccessController->death_reports($_POST['daydropdown'],$_POST['monthdropdown'],$_POST['yeardropdown'],$_POST['dreport_place'], $_POST['dreport_address'], $_POST['dreport_additional']);
    if ($death) {
          echo"<p><font  color=red  size='5pt' > Your Death Report has been Registered</font></p>";
        header("Refresh:3;url='newhome.php'");
        } 
}
然后使用

header("Refresh:3;url='newhome.php'");
代码的其余部分永远不会执行

编辑

代码中仍有以下代码块

if ($_SERVER["REQUEST_METHOD"] == "POST")
{
  //Move_Me
}
将代码
Move_Me
包装入

if(isset($_POST['report']))
{
  //MoveD_Me
}
移除

if ($_SERVER["REQUEST_METHOD"] == "POST") 

阻塞。

问题是所有表单都具有相同的提交条件

$_SERVER["REQUEST_METHOD"] == "POST"
为提交按钮指定一个唯一的名称,如下所示

<input type="submit" value="Save" name="btnsize1" />
这将只提交所需的表单。当然,您需要从更新第一部分(从
$\u POST
值中初始化变量)


问题与php文件中的内容有关。脚本运行良好,与您的问题无关。请将代码包含在php文件中。我已经包含了一个php文件。请查看。您应该首先删除php文件中额外的
标记。在您提供的第一个页面中已经有1个html和body标记。那是一个正常工作的php文件吗?所有3个单独工作都很好。所以wicheva是选项卡中第一个正常工作的文件。但是第二个和第三个不正常。如果我在第一个选项卡中对它进行gv,那么这就正常了。我想所有Report.php文件提交表单的条件都是一样的:
$\u SERVER[“REQUEST\u METHOD”]=“POST”
。我说的对吗?表单是否仍同时提交?提交时会出现错误。”未定义的索引'.Ooh!!是的!!我的错误。。。您应该在提交按钮属性上使用
name
而不是
id
。我已经更新了提交按钮上的代码。我还添加了第一次提交部分的更正。现在就试试吧@杰米娜:你试过上次更新的代码了吗?你能给我一些反馈吗?是的…我在插入查询功能中使用了exit,所以插入现在可以工作了,但其他问题如日期不显示…(我已经将所有插入查询包含在一个文件中。因此,只有插入成功后,它才会转到newhome.php。我做了与你所说的相同的操作…但仍然是一样的:(您是否对所有提交按钮使用相同的
name
值?如何处理服务器端的每个表单?好的,如果您已经相应地更新了所有三个php文件,这应该可以工作。您已经从所有三个按钮中删除了
if($\u server[“REQUEST\u METHOD”]==“POST”)
块,对吗?并将数据库逻辑包装在
if(isset)中对于Report1.php,($\u POST['report'])
对于report2.php,
if(isset($\u POST['report2'])
对于report2.php和
if(isset($\u POST['report3'])
对于report3.php,如果看不到最新的代码,就无法再继续进行下去。
<input type="submit" value="Save" name="btnsize1" />
if(isset($_POST['btnsize1']))
if(isset($_POST['report']))
if(isset($_POST['btnsize1']))