newbienewbie Posted February 28, 2007 Share Posted February 28, 2007 <html> <body> Username: <input name="username" type="text" size="10" maxlength="30" VALUE="This is my text username"/> Password: <input name="password" type="password" size="10" maxlength="4" /> <input type="submit" value="Login" /> <?php echo $_REQUEST['username']; echo $_REQUEST['password']; ?> </body> </html> echo $_REQUEST['username']; statement is not printing username value. why? Quote Link to comment Share on other sites More sharing options...
magnetica Posted February 28, 2007 Share Posted February 28, 2007 Wheres the code for storing the Username variable this may be the problem Quote Link to comment Share on other sites More sharing options...
magnetica Posted February 28, 2007 Share Posted February 28, 2007 You forgot the <form> tags. Try this and let me know if it works <html> <body> <form action="" method="post"> Username: <input name="username" type="text" size="10" maxlength="30" VALUE="This is my text username"/> Password: <input name="password" type="password" size="10" maxlength="4" /> <input type="submit" value="Login" /> </form> <?php echo $_REQUEST['username']; echo $_REQUEST['password']; ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
TRI0N Posted February 28, 2007 Share Posted February 28, 2007 if you load that same page and at the end of your address MyPageName.php?username=Roboto&password=GodMode You should get the responce your looking for.. However that is no way safe to be passing thru a password. The page before shouel have.. $_SESSION['username'] = 'roboto' ; $_SESSION['password'] = 'godmode' ; The page you want to display it: <?php echo $_SESSION['username'].'<br>' ; echo $_SESSION['password'] ; ?> This way that critical information is not passed thru with a URL address. Quote Link to comment Share on other sites More sharing options...
TRI0N Posted February 28, 2007 Share Posted February 28, 2007 Uh duh I didn't even relize that was a form util you corrected that LOL. Quote Link to comment Share on other sites More sharing options...
cuteNephilim Posted February 28, 2007 Share Posted February 28, 2007 And in the case of a POST form try: <?php echo $_POST['username']; echo $_POST['password']; ?> instead of <?php echo $_REQUEST['username']; echo $_REQUEST['password']; ?> if this isn't already done... Quote Link to comment Share on other sites More sharing options...
newbienewbie Posted February 28, 2007 Author Share Posted February 28, 2007 no luck . not working with form tag, not even with _SESSION and _POST. suggestions? Quote Link to comment Share on other sites More sharing options...
magnetica Posted February 28, 2007 Share Posted February 28, 2007 <?php echo $_POST['username']; echo $_POST['password']; ?> instead of <?php echo $_REQUEST['username']; echo $_REQUEST['password']; ?> But theres no difference unless im mistaken.. Quote Link to comment Share on other sites More sharing options...
magnetica Posted February 28, 2007 Share Posted February 28, 2007 no luck . not working with form tag, not even with _SESSION and _POST. suggestions? Well i used this code on my local server and it worked fine: <html> <body> <form action="" method="post"> Username: <input name="username" type="text" size="10" maxlength="30" VALUE="This is my text username"/> Password: <input name="password" type="password" size="10" maxlength="4" /> <input type="submit" value="Login" /> </form> <?php echo $_REQUEST['username']; echo $_REQUEST['password']; ?> </body> </html> Are you running this on a local server or on a remote server (your hosting service) Quote Link to comment Share on other sites More sharing options...
newbienewbie Posted February 28, 2007 Author Share Posted February 28, 2007 local test server , i can only see (attached file) http://127.0.0.1:8080/testing/login.php [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
magnetica Posted February 28, 2007 Share Posted February 28, 2007 Dont know if it will make a difference but try http://127.0.0.1/testing/login.php OR http://localhost/testing/login.php Should work, let me know Quote Link to comment Share on other sites More sharing options...
itsmeArry Posted February 28, 2007 Share Posted February 28, 2007 did u submit the form.. because what i see is that if you pass the parameters in querystring it will display them and untill or unless the form is not submitted it will not display the values. Quote Link to comment Share on other sites More sharing options...
newbienewbie Posted February 28, 2007 Author Share Posted February 28, 2007 magnetica, my apache is running on port 8080, so i must pass 8080. and it is not working with or without 8080. Quote Link to comment Share on other sites More sharing options...
magnetica Posted February 28, 2007 Share Posted February 28, 2007 Oh ok sorry.. Well I testing the code on my local server and it worked just fine. Do you have webspace you can upload it to and try? Quote Link to comment Share on other sites More sharing options...
cuteNephilim Posted February 28, 2007 Share Posted February 28, 2007 <?php echo $_POST['username']; echo $_POST['password']; ?> instead of <?php echo $_REQUEST['username']; echo $_REQUEST['password']; ?> But theres no difference unless im mistaken.. That should not be a problem, no, unless you run an early PHP version (prior to 4.1.0 I think). Quote Link to comment Share on other sites More sharing options...
TRI0N Posted February 28, 2007 Share Posted February 28, 2007 Create a new page and put just this in it and view it. <?php phpinfo(); ?> Quote Link to comment Share on other sites More sharing options...
nloding Posted February 28, 2007 Share Posted February 28, 2007 Check your version of PHP using phpinfo() ... And if none of the previous code samples are working, no offense, I think you copied them wrong. You have to hit submit, and the form action has to be "" so it reloads the same page. The form method must be POST. SESSION variables won't work unless you've started a session and created them. And if this is truly a login form that will actually be used, and not just you goofing around, you'll want to learn sessions and how to create secure user authentication. Google it. If you're looking for on-the-fly displaying of the stuff you type into the box, you need both PHP and Javascript and create an Ajax call to update the page. That's a lot of work for displaying what is already displayed on the page. Quote Link to comment Share on other sites More sharing options...
newbienewbie Posted February 28, 2007 Author Share Posted February 28, 2007 phpinfo is working fine, i am using php5 and mysql5 Quote Link to comment Share on other sites More sharing options...
ashly Posted February 28, 2007 Share Posted February 28, 2007 try the code below: <html> <body> <form action="" method="post"> Username: <input name="username" type="text" size="10" maxlength="30" VALUE="This is my text username"/> Password: <input name="password" type="password" size="10" maxlength="4" /> <input type="submit" value="Login" /> </form> <?php echo $_REQUEST['username']; echo $_REQUEST['password']; ?> </body> </html> hey, just enter some values for Username and Password columns and click on the Login button. You will get something printed ..sure... is it? Quote Link to comment Share on other sites More sharing options...
nloding Posted February 28, 2007 Share Posted February 28, 2007 If you copy and paste ashly's code exactly, type something into the username and password boxes and submit it, it will display the variables. Quote Link to comment Share on other sites More sharing options...
newbienewbie Posted March 1, 2007 Author Share Posted March 1, 2007 Thanks you all, when i entered values in username and password and click login button it displayed values. thanks again. but newbie have questions, why it doesn't prints default value "This is my text username" on executing login.php form for the first time? why it prints value only after clicking login button? Quote Link to comment Share on other sites More sharing options...
itsmeArry Posted March 1, 2007 Share Posted March 1, 2007 because you are using $_REQUEST method to print the value and the form has the method post. When the form gets submitted the value is posted and $_REQUEST finds that value and prints that. when the form is not submitted the $_REQUEST will not get anything untill you pass anything in querystring. 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.