I am trying to use post in a form to save form data from a dropdown as a session in the same file as the form
<?php
session_start();
if(isset($_SESSION['post-data']['surnameid']))
unset($_SESSION['post-data']['surnameid']);
?>
Then in the body of html
<form action="" method="post">
<?php
include 'connect.inc';
$sql = "SELECT surnameid FROM customer";
$result = mysql_query($sql);
echo "<select name='surnameid'>";
while ($row = mysql_fetch_array($result)) {
echo "<option value='" . $row['surnameid'] . "'>" . $row['surnameid'] . </option>";
}
include 'close.inc';
?>
<br/>
<input type="submit" name="Submit" value="Submit!" />
</form>
<?php
$_SESSION['post-data'] = $_POST;
echo $_SESSION['post-data']['surnameid'];
?>
The assiginment to $_SESSION does not work