italiano40 Posted June 26, 2007 Share Posted June 26, 2007 <html> <head> <title>Welcome please login</title> </head> <body> <body bgcolor="#ff3333"> <form action="login.php" method="post"> <p>Username: <input type="text" name="username" /></p> <p>Password: <input type="password" name="password" /></p> <p><input type="submit"/><input type="reset" /></p> <p><a href="createaccount.htm">Create an Account</a></c></p> </form> </body> </html> <?php if($_POST["username"]=="italiano40" && $_POST["password"]=="mafia2") echo $_REQUEST["username"]; else echo $_REQUEST["password"]; ?> how come it will not print the password and username, i just get a blank page Quote Link to comment Share on other sites More sharing options...
trq Posted June 26, 2007 Share Posted June 26, 2007 You have an if() clause that prevents it from printing both, but it should print one of them. Quote Link to comment Share on other sites More sharing options...
suma237 Posted June 26, 2007 Share Posted June 26, 2007 try this <? if(isset($_POST['login'])){ if($_POST["username"]=="abc" && $_POST["password"]=="abc") echo $_REQUEST["username"]; else echo $_REQUEST["password"]; } ?> <html> <head> <title>Welcome please login</title> </head> <body> <body bgcolor="#ff3333"> <form action="<?=$_SERVER[php_SELF]?>" method="post"> <p>Username: <input type="text" name="username" /></p> <p>Password: <input type="password" name="password" /></p> <p><input type="submit" name="login" value="LOGIN"/> <input type="reset" /></p> <p><a href="createaccount.htm">Create an Account</a></c></p> </form> </body> </html> Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted June 26, 2007 Share Posted June 26, 2007 try it like this: <?php if(isset($_POST['submit'])){ if($_POST["username"]=="italiano40" && $_POST["password"]=="mafia2"){ echo $_REQUEST["username"]; echo $_REQUEST["password"]; } }else{echo "Nothing to display";} ?> Quote Link to comment Share on other sites More sharing options...
italiano40 Posted June 26, 2007 Author Share Posted June 26, 2007 still doesn't work but it is 2 different files one is html and one is PHP and it works because if i ask it to redirect to other webpages it works but when it tries to print to the screen it doesn't work is their anything else i can do expect print because that doesn't work either. Quote Link to comment Share on other sites More sharing options...
suma237 Posted June 26, 2007 Share Posted June 26, 2007 html <html> <head> <title>Welcome please login</title> </head> <body> <body bgcolor="#ff3333"> <form action="login.php" method="post"> <p>Username: <input type="text" name="username" /></p> <p>Password: <input type="password" name="password" /></p> <p><input type="submit" name="login" value="LOGIN"/> <input type="reset" /></p> <p><a href="createaccount.htm">Create an Account</a></c></p> </form> </body> </html> login.php <? if(isset($_POST['login'])){ if($_POST["username"]=="abc" && $_POST["password"]=="abc") echo $_REQUEST["username"]; else echo $_REQUEST["password"]; }?> Quote Link to comment Share on other sites More sharing options...
italiano40 Posted June 26, 2007 Author Share Posted June 26, 2007 for some reason it doesn't print to the screen Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted June 26, 2007 Share Posted June 26, 2007 try it with user name abc and password abc than it will show you the user name and pass. Or if not working then try to change to this: if(isset($_POST['login'])){ if($_POST["username"]=="abc" && $_POST["password"]=="abc"){ echo $_POST["username"]; else echo $_POST["password"]; } } Quote Link to comment Share on other sites More sharing options...
suma237 Posted June 26, 2007 Share Posted June 26, 2007 are you able to redirect the html page to login.php Quote Link to comment Share on other sites More sharing options...
italiano40 Posted June 26, 2007 Author Share Posted June 26, 2007 no when i replace echo with a redirect it works perfectly but i need it to print it to the screen Quote Link to comment Share on other sites More sharing options...
suma237 Posted June 26, 2007 Share Posted June 26, 2007 <html> <head> <title>Welcome please login</title> </head> <body> <body bgcolor="#ff3333"> <form action="login.php" method="post"> <p>Username: <input type="text" name="username" /></p> <p>Password: <input type="password" name="password" /></p> <p><input type="submit" name="login" value="LOGIN"/> <input type="reset" /></p> <p><a href="createaccount.htm">Create an Account</a></c></p> </form> </body> </html> When you enter abc as username and abc as password it will redirect to login.php NOW .. Try to echo the post value simply using login.php <? echo'<pre>'; print_r($_POST); echo'</pre>'; ?> ?> Quote Link to comment Share on other sites More sharing options...
suma237 Posted June 26, 2007 Share Posted June 26, 2007 try to solve this ,code is very simple 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.