I actually mislead you a bit because I didn't realise you were submitting the form page to itself in which case you don't need sessions at all. Sorry 
I would do something like this.
PHP Code:
<?php
if(isset($_POST['submit'])) {
//do some processing here and then set the class values
//for the form and message containers
$formClass = 'hide';
$msgClass = 'show';
unset($_POST['submit']);
} else {
$formClass = 'show';
$msgClass = 'hide';
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style type="text/css">
.show {
display: block
}
.hide {
display: none
}
</style>
</head>
<body>
<form class="<?php echo $formClass; ?>" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" >
<input type="text" name="txtEmail" />
<input type="submit" value="Submit" name="submit" />
</form>
<div class="<?php echo $msgClass; ?>">
Thank you for your email
</div>
</body>
</html>
Bookmarks