Need help integrating form validation.
Posted: Wed Aug 05, 2009 10:47 pm
I have a simple script which should pass the variable $Name from Pass.php to Pass2.php, but for some reason on Pass2.php $Name is Undefined. Here is my script:
Pass.php
Pass2.php
Can anyone tell me why my code isn't working?
Pass.php
Code: Select all
<?php
$Name = $_POST['Name'];
if (!empty($Name)) {
header("Location: pass2.php");
}
?>
<!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=utf-8" />
<title>SC Form Version 1.0</title>
<script type="text/javascript" src="SCscript.js"></script>
<link rel="stylesheet" type="text/css" href="SCstyle.css" />
</head>
<body>
<form action="pass.php" method="post">
<?php
foreach ($_POST as $key => $val) {
echo '<input type="hidden" name="' . $key . '" value="' . $val . '" />' . "\r\n";
}
?>
<span>Name:<input type="text" name="Name" /></span><br />
<input type="submit" name="Submit" value="Step 2" /><br />
</form>
</body>
</html>Code: Select all
<?php
$Name = $_POST['Name'];
?>
<!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=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
echo $Name;
?>
</body>
</html>