执行这个PHP程序?

时间:2017-03-12 12:40:30

标签: javascript php

我无法让这个程序正常运行。我确信我拥有所有正确的语法,括号等...但是,它只是吐出放入其中的代码,我错过了什么?

程序应该在执行JavaScript程序后从post方法发布。

<!DOCTYPE HTML>
<html lang="EN" dir="ltr" xmin="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="content-type" content="text/xml; charset=utf-8" />
        <title>Site.php</title>
    </head>
    <body>
        <form id="myform" method="Post" action="Site.php">
            <center><table><tr>
                        <td align="center"><input type="text" name="mo" value="<?php echo $_SESSION['mo']; ?>" size="4"/></td>
                        <td align="center"><input type="text" name="dy" value="<?php echo $_SESSION['dy']; ?>" size="4"/></td>
                        <td align="center"><input type="text" name="yr" value="<?php echo $_SESSION['yr']; ?>" size="4"/></td>
                        <td align="center"><input type="text" name="hr" value="<?php echo $_SESSION['hr']; ?>" size="4"/></td>
                        <td align="center"><input type="text" name="mn" value="<?php echo $_SESSION['mn']; ?>" size="4"/></td>
                        <td align="center"><input type="text" name="sc" value="<?php echo $_SESSION['sc']; ?>" size="4"/></td>
                    </tr</table></center>
        </form>
    </body>
</html>

<?php
$mo = filter_input(INPUT_POST, "mo");
$dy = filter_input(INPUT_POST, "dy");
$yr = filter_input(INPUT_POST, "yr");
$hr = filter_input(INPUT_POST, "hr");
$mn = filter_input(INPUT_POST, "mn");
$sc = filter_input(INPUT_POST, "sc");

session_start();

$_SESSION['mo'] = $mo;
$_SESSION['dy'] = $dy;
$_SESSION['yr'] = $yr;
$_SESSION['hr'] = $hr;
$_SESSION['mn'] = $mn;
$_SESSION['sc'] = $sc;
$_SESSION['count'] = $count;

session_write_close();
?>

1 个答案:

答案 0 :(得分:1)

1。将session_start()带到页面顶部。

2。验证您的计数变量,因为它不存在..可能是您从其他地方加载它,执行此操作isset($count) ? $count : "";

3。向表单添加提交按钮,以便在会话中存储数据。