donkru,
please use [ php] and [ /php] bbcode tags (without spaces) when posting code.
focus310,
On your first page you are checking for POST data. If that post data exists, then you set the session. In the same file you are posting to the second page, which sets the session as the name.
Additionally, I don't see any session_start(); command which is required when using sessions.
IF you are trying to get the person's name, and verify that it is there before continuing, try this (I checked it here and it worked, except for the include and your escape_data function)
named page1 and page2, sorry you'll have to fix up the form fields
page1 ------>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<?php
//include('header_app.html');
error_reporting(E_ALL);
session_start();
$error = $_SESSION['error']; // will be boolean value
$error_msg = $_SESSION['errormsg'];
if ($error == true) {
if (is_array($error_msg)) { // If error is an array, display all error messages
foreach ($error_msg as $key => $msg) {
echo "Error $key: $msg<br>";
}
} else { // If its just a variable, spit itout...
echo "Error: $error_msg";
}
}
?>
<form method="post" action="page2.php">
<table class="apptable">
<tr><td class="a"><b>Application Completed by:</b></td><td class="b"><input type="text" name="complete" size="25" value="<?php if (isset($_SESSION['complete'])) echo $_SESSION['complete']; ?>"></td></tr>
</table>
<input type="submit" name="btnSubmit" id="btnSubmit" value="Page 2 >>" class="btn" >
<input type="hidden" name="submitted" value="TRUE" />
</form>
</body>
</html>
And now for page 2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<?php
include('header_app.html');
session_start();
$errors = array();
if (empty($_POST['complete'])) {
$errors[] = 'Name is a required field, Please enter your name.';
$_SESSION['error'] = true;
$_SESSION['errormsg'] = $errors;
header("Location: page1.php");
} else { // Display the 2nd form only if they have completed everything
$_SESSION['complete'] = escape_data($_POST['complete']);
?>
You did it!
<form action="app_admission_pg3.php" method="post" >
</form>
<?php
}
?>
</body>
</html>
This validates that they wrote their name, if not it makes an error message and sends 'em back to page 1.
You can really modify this to do whatever you want, (validation wise).
edit {
I am having it display the array key (from the error messages) to "count" the errors, it will start at 0. Its not needed, but just something for fun.
}
If you have any questions, please let me know.