Php:帖子表单不起作用

时间:2013-04-12 14:23:18

标签: php html

好的,所以我在呼叫中心工作,我们有一个监视器,显示每个呼叫者已经休息的休息时间。我是这家公司的新手,并且已经完成了为这台显示器制作网站的任务。

下面是我的PHP代码。 我已经搜索了可能存在的问题,但我似乎无法找到它。

问题是:如果我点击按钮,那么我的表单不会被发布,也不会写入csv。代码在之前的主线中已经工作了,我知道我的代码是正确的。它必须是愚蠢和小的东西,但我找不到它。

我的代码:

<html>
<head>
<LINK REL="StyleSheet" HREF="Input_form.css">
<title>Verander Plaatsindeling</title>
<h1><center>Verander plaatsindeling<center></h1>
<hr/>
</head>
<body>
    <?php
        if(ISSET($_POST['submitMe']))
        {
        $csv = fopen("zitplaatsenAntwerpen.csv","w") or die("Kan csv niet vinden!");

        for($counter=1;$counter<=30;$counter++)
        {
            $naam = $_POST["Naam" .$counter];
            $project = $_POST["Project" .$counter];
            $csvrow = $counter . ";" . $naam . ";" . $project . "\n";
            fwrite($csv, $csvrow);
        }
    ?>
     <?php
            fclose($csv);
            echo "<SCRIPT LANGUAGE='JavaScript'>
            <!--
            window.alert('Gegevens ingeladen!')
            // -->
            </SCRIPT>";
            $informatie = array();
            $f = fopen("ZitplaatsenAntwerpen.csv","r") or die("Kan csv niet vinden!");

            while (!feof($f))
            {
                $arrM = explode(";",fgets($f));
                $informatie[$arrM[0]]["Nummer"] = ucwords($arrM[0]);
                $informatie[$arrM[0]]["Naam"] = ucwords($arrM[1]);
                $informatie[$arrM[0]]["Project"] = ucwords($arrM[2]);
            }
            fclose($f);
        }
        else
        {
            $informatie = array();
            $f = fopen("ZitplaatsenAntwerpen.csv", "r")  or die("Kan csv niet vinden!");

            while (!feof($f))
            {
            $arrM = explode(";",fgets($f));
            $informatie[$arrM[0]]["Nummer"] = ucwords($arrM[0]);
            $informatie[$arrM[0]]["Naam"] = ucwords($arrM[1]);
            $informatie[$arrM[0]]["Project"] = ucwords($arrM[2]);
            }
            fclose($f);
        }
     ?>
     <div style="word-spacing:7em;" align:center>
      Nummer    Naam    Project
     </div>

    <pre><form action="<?php echo $PHP_SELF;?>" method="post">
    <?php
        for ($teller = 1;$teller<=30; $teller++)
        {
                if(!empty($informatie[$teller]))
                {
                    echo "<div align:center>";
                    echo  "     " . $teller . "   ";
                    echo "<input type='text' name='Naam" .$teller. "' value='";
                    echo $informatie[$teller]["Naam"] . "'>";
                    echo "<input id='" .$teller. "' ";
                    echo "<input type='text' name='Project" .$teller. "' value='";
                    echo $informatie[$teller]["Project"] . "'>";
                    echo "</div>";
                }
                else
                {
                    echo "<div align:center>";
                    echo "      " . $teller . "   ";
                    echo "<input type='text' name='Naam" .$teller. "' value='";
                    echo $informatie[$teller]["Naam"] . "'>";
                    echo "<input id='" .$teller. "' ";
                    echo "<input type='text' name='Project" .$teller. "' value='";
                    echo $informatie[$teller]["Project"] . "'>";
                    echo "</div>";
                }
        }
    ?>
    </form></pre>
<div align="center">
<button style="width:100;height:50" type="submit" name="submitMe">Opslaan</button>
</div>
</body>
</html>

任何帮助将不胜感激。 提前谢谢大家

3 个答案:

答案 0 :(得分:2)

更改此PHP

if(ISSET($_POST['submitMe']))

用这个:

if(isset($_POST['submitMe']))

您已在关闭的表单之后放置提交按钮尝试制作如下内容:

<input type="submit" style="width:100;height:50"  name="submitMe" value="Opslaan">
</form>

答案 1 :(得分:1)

您的提交按钮位于<form>标记之外。查看页面的来源,您会发现它呈现为:

<form>
....
</form>
<button...>

button应该位于表单标记内:

<form>
<button ...>
</form>

答案 2 :(得分:0)

此代码错误,

<button style="width:100;height:50" type="submit" name="submitMe">Opslaan</button>

你应该使用

<input style="width:100;height:50" type="submit" name="submitMe" value="Opslaan" />
相关问题