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 Link to comment https://forums.phpfreaks.com/topic/29809-php5-_post/ 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] Link to comment https://forums.phpfreaks.com/topic/29809-php5-_post/#findComment-136885 Share on other sites More sharing options...
Terramoto Posted December 7, 2006 Author Share Posted December 7, 2006 Array() Link to comment https://forums.phpfreaks.com/topic/29809-php5-_post/#findComment-136887 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]. Link to comment https://forums.phpfreaks.com/topic/29809-php5-_post/#findComment-136890 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 Link to comment https://forums.phpfreaks.com/topic/29809-php5-_post/#findComment-136894 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] Link to comment https://forums.phpfreaks.com/topic/29809-php5-_post/#findComment-136896 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]. Link to comment https://forums.phpfreaks.com/topic/29809-php5-_post/#findComment-136902 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] Link to comment https://forums.phpfreaks.com/topic/29809-php5-_post/#findComment-136904 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.