Terramoto Posted December 7, 2006 Share Posted December 7, 2006 hi, i made a simple php page:[quote]<?phpecho $_POST["username"];?><form action="this.php" method="POST" enctype="text/plain"> <input type="text" name="username" size="40" maxlength="40"/> <input type="submit" name="submit" value="Login"/></form>[/quote]im using php 5.2.0 and apache 2.0.59,and the $_POST returns nothing...any hint? ,tks Quote Link to comment Share on other sites More sharing options...
trq Posted December 7, 2006 Share Posted December 7, 2006 Code looks fine except it will generate a notice until the form is submitted. What does this output?[code]<?php print_r($_POST);?><form action="this.php" method="POST" enctype="text/plain"> <input type="text" name="username" size="40" maxlength="40"/> <input type="submit" name="submit" value="Login"/></form>[/code] Quote Link to comment Share on other sites More sharing options...
Terramoto Posted December 7, 2006 Author Share Posted December 7, 2006 Array() Quote Link to comment Share on other sites More sharing options...
trq Posted December 7, 2006 Share Posted December 7, 2006 Hate to ask but this is happening after you submit the form? The page is called this.php? try removing [i]enctype="text/plain[/i]. Quote Link to comment Share on other sites More sharing options...
Terramoto Posted December 7, 2006 Author Share Posted December 7, 2006 bahh...stupid error...the enctype...:pgot to see more about enctype X)tks Quote Link to comment Share on other sites More sharing options...
marcus Posted December 7, 2006 Share Posted December 7, 2006 You can do:[code]<?phpif(!isset($_POST[username]){echo "<form action=this.php method=POST>\n";echo "<input type=text name=username size=40 maxlength=40/>\n";echo "<input type=submit name=submit value=Login/>\n";echo "</form>\n";}else {echo "$_POST[username]";}?>[/code] Quote Link to comment Share on other sites More sharing options...
trq Posted December 7, 2006 Share Posted December 7, 2006 Sorry mgallforever but its $_POST['username'] not $_POST[username]. Quote Link to comment Share on other sites More sharing options...
papaface Posted December 7, 2006 Share Posted December 7, 2006 ^^ With all in mind, code will be:[code]<?phpif (isset($_POST["username"])) { echo $_POST["username"]; } else { echo ' <form action="this.php" method="POST" > <input type="text" name="username" size="40" maxlength="40"/> <input type="submit" name="submit" value="Login"/></form>'; }?>[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.