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 Link to comment https://forums.phpfreaks.com/topic/57216-i-need-help-with-a-very-simple-code/ 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. Link to comment https://forums.phpfreaks.com/topic/57216-i-need-help-with-a-very-simple-code/#findComment-282809 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> Link to comment https://forums.phpfreaks.com/topic/57216-i-need-help-with-a-very-simple-code/#findComment-282811 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";} ?> Link to comment https://forums.phpfreaks.com/topic/57216-i-need-help-with-a-very-simple-code/#findComment-282812 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. Link to comment https://forums.phpfreaks.com/topic/57216-i-need-help-with-a-very-simple-code/#findComment-282813 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"]; }?> Link to comment https://forums.phpfreaks.com/topic/57216-i-need-help-with-a-very-simple-code/#findComment-282814 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 Link to comment https://forums.phpfreaks.com/topic/57216-i-need-help-with-a-very-simple-code/#findComment-282816 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"]; } } Link to comment https://forums.phpfreaks.com/topic/57216-i-need-help-with-a-very-simple-code/#findComment-282819 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 Link to comment https://forums.phpfreaks.com/topic/57216-i-need-help-with-a-very-simple-code/#findComment-282820 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 Link to comment https://forums.phpfreaks.com/topic/57216-i-need-help-with-a-very-simple-code/#findComment-282821 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>'; ?> ?> Link to comment https://forums.phpfreaks.com/topic/57216-i-need-help-with-a-very-simple-code/#findComment-282825 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 Link to comment https://forums.phpfreaks.com/topic/57216-i-need-help-with-a-very-simple-code/#findComment-282828 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.