luxeon Posted July 9, 2009 Share Posted July 9, 2009 Please help it's not work <html> <body> <form name="form" action="index.php" method="post"> <input name="x" type="text"> <input name="y" type="submit" value="oK"> </form> <?php $x=$_POST['x']; if(isset($_POST['y'])) { echo $x; } else {echo "tralala";} ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/165385-trouble-with-easy-code/ Share on other sites More sharing options...
ignace Posted July 9, 2009 Share Posted July 9, 2009 <html> <body> <form name="form" action="index.php" method="post"> <input name="x" type="text"> <input name="y" type="submit" value="oK"> </form> <?php if (!empty($_POST)) { if (isset($_POST['x'])) { print $_POST['x']; } if (isset($_POST['y'])) { print $_POST['y']; } } else { print 'tralala'; } ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/165385-trouble-with-easy-code/#findComment-872215 Share on other sites More sharing options...
webref.eu Posted July 9, 2009 Share Posted July 9, 2009 I've modified your code slightly, see below. The code is "working" how I would expect it to, it depends what you want it to do ... You can see the below script running on my server at: http://www.computer-monitors.org.uk/test-simple.php Rgds <html> <body> <?php $x=$_POST['x']; if(isset($_POST['y'])) { echo $x; } else {echo "tralala";} ?> <form name="form" action="<? echo $_SERVER['PHP_SELF']; ?>" method="post"> <input name="x" type="text"> <input name="y" type="submit" value="ok"> </form> </body> </html> Link to comment https://forums.phpfreaks.com/topic/165385-trouble-with-easy-code/#findComment-872227 Share on other sites More sharing options...
luxeon Posted July 9, 2009 Author Share Posted July 9, 2009 ooo thanks webref.eu, I want do exactly that you showed me.. Link to comment https://forums.phpfreaks.com/topic/165385-trouble-with-easy-code/#findComment-872228 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.