php question
I am having trouble with using a hidden field the actual code is really simple:
<?php session_start(); echo $_POST['error'];
?> <html> <body> <table border ="0" cellspacing ="0" cellpadding="0" style="margin-left:25px;"> <!-- login table --> <tr><td colspan="2"><h1>Login Details:</h1></td></tr> <tr><td colspan ="2"><img src="spacer.gif" height="15px"</td></tr> <tr> <td style ="font-size:16pt; font-family:Arial;"> <form ACTION="hidden.php" Method="POST"> <label for="uname"> Username: </label> </td> <td> <input id="uname" style="height:40px;padding-top:10px; font-size:16px;" type ="text" Name="userName" /> </td> <tr><td colspan ="2"><img src="spacer.gif" height="15px"/></td></tr> </tr> <tr> <td style ="font-size:16pt; font-family:Arial;"> <label for="pass"> Password: </label> </td> </td> <td> <input type ="password" id="pass" style="height:40px;padding-top:10px;font-size:16px;" Name="password"/> <a href="forgotpass.htm" style="font-size:16pt; text-decoration:none;">Forgotten your Password</a> </td> </tr> <tr> <td colspan="2"> <input type="hidden" name="error" value="big" /> <input type="submit" value="Log In"/ style="font-size:16pt; font-family:Arial;color:white;"/> </form> </td> </tr> <tr> <td><img src="spacer.gif" height="15px"/></td> <td style="font-size:16pt;" align="right">Please enter your username and password</td> </tr> <tr> <td></td> <td><?php echo $_POST['error']; ?></td> <!--error tag --> </tr> </table> </td> </tr> </table> </td> </tr> </table> </body> <?php $_POST['error'] = "Hello"; echo $_POST['error']; ?> when I click the submit button the word big comes out onto the screen as expected.This is becasue it is hard wired into the value filed of the hidden field.
However if I change it to <input type="hidden" name="error" value="<?php echo $_POST['error'];?>" /> it wont set it and prints a blank
if I try setting a variable and putting that as the echo value it still prints a blank..?
As you can see at the bottom of the page the last line of code sets the post variable to hello but that is not printed after the submit button is clicked..? Started By Laurencek on Feb 22, 2010 at 4:23:16 AM |