user7582130
user7582130

Reputation:

Executing this PHP program?

I am not able to get this program working. I'm sure I have all the correct syntax, brackets etc... However, it just spits out code that is put into it, am I missing anything?

The program should post upon itself from the post method, after executing a JavaScript program.

<!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();
?>

Upvotes: 0

Views: 48

Answers (1)

f_i
f_i

Reputation: 3342

1 . Take your session_start() to the top of your page.

2 . validate your count variable as it doesn't exists.. may be you are loading it from somewhere else, do this isset($count) ? $count : "";

3 . Add a submit button to your form in order to store data in your session.

Upvotes: 1

Related Questions