|
Posted by number1.email on 09/28/60 11:45
Hello,
I'm having some problems in passing hidden fields from one Web Page to
another and was wondering if anyone could help me out.
Basically, I have a Web Page (ie: page1.php) with code:
-----------------------------------------------------------------------------------------------------------
<html>
<head><title>Test Web Page</title>
<script language="javascript">
function chkForm(formObj)
{
// Validation Scripts will go here...
}
</script>
</head>
<body bgcolor=#ffffff>
<form action="page2.php" method="post" name="myForm"><BR>
<form name="myForm" onSubmit="return chkForm(this.form);"
action="page2.php" method="post">
<?php
error_reporting(E_ALL);
$username = "Sally Jones";
?>
<input type="hidden" name="username" value=<?php echo $username; ?> >
<hr align='left' width='60%' noshade></tr>
<input type="submit" value="Submit Answers" onclick="return
chkForm(this.form)">
</form>
</body>
</html>
-----------------------------------------------------------------------------------------------------------
When the user clicks on "Submit Answers", it calls the following Web
Page (ie: page2.php) :
<HTML>
<HEAD><TITLE>INSERT Data via PHP</TITLE></head>
<BODY>
<form action="page1.php" method="post">
<?PHP
error_reporting(E_ALL);
echo "Hello: ";
echo $username;
?>
<BR><BR>
<input type="submit" value="Want to go back?">
<input type="hidden" name="username" value="<?PHP echo $username; ?>">
</form>
</BODY>
</HTML>
-----------------------------------------------------------------------------------------------------------
I'm getting errors on the hidden fields that I'm trying to pass. For
example, I would expect to see
Hello: Sally Jones
but instead, I get:
Notice: Undefined variable: username in
/export/home/my/newsite.com/public_html/page2.php on line 12
Can anyone advise me on what is wrong...and how to correct it?
Thanks...
Navigation:
[Reply to this message]
|