RadiationHazard Posted August 30, 2008 Share Posted August 30, 2008 so I got this code from someone on here about a year ago and I messed it up some how. does anyone know what I did? <?php $username = "username"; $password = "password"; if ($_POST['txtUsername'] != $username || $_POST['txtPassword'] != $password) { ?> <form action="<?=$_SERVER['PHP_SELF']; ?>" method="post" name="form"> <h1>Login</h1> <table> <tbody> <tr> <td>Username:</td> <td><input type="text" name="txtUsername" /></td> </tr> <tr> <td>Password:</td> <td><input type="text" name="txtPassword" /></td> </tr> <tr> <td align="right" colspan="2"><input type="submit" /><input type="reset" /></td> <?php } else { header('location: http://www.website.com/'); } ?> what this does is if you put in the right password it takes you to the website it's basically a password protected redirect. it's just for something simple I know it's not very secure if someone does get pass I'm not that worried about it I just want to keep as many unwanted people out as possible. also if you could make it to where the password is stars or circles that'd be amazing! thank you in advance for your time. Link to comment https://forums.phpfreaks.com/topic/122031-need-help-fixing-this-code/ Share on other sites More sharing options...
Fadion Posted August 30, 2008 Share Posted August 30, 2008 For the password to appear as masked, change the password input to: <input type="password" name="txtPassword" /> As for the rest of the code, what problems are you having with it? Link to comment https://forums.phpfreaks.com/topic/122031-need-help-fixing-this-code/#findComment-629927 Share on other sites More sharing options...
RadiationHazard Posted August 30, 2008 Author Share Posted August 30, 2008 here we go. here is the code <?php $username = "admin"; $password = "password"; if ($_POST['txtUsername'] != $username || $_POST['txtPassword'] != $password) { ?> <form name="form" method="post" action="<?=$_SERVER['PHP_SELF']; ?>"> <h1>Login</h1> <table> <tr> <td>Username: <td><input type="text" name="txtUsername"> <tr> <td>Password: <td><input type="text" name="txtPassword"> <tr> <td colspan=2 align=right><input type="submit"><input type="reset"> </form> <?php } else { header('location: http://www.google.com'); } ?> and they I just add what guiltygear said and it works better than ever before! thanks so much!! Link to comment https://forums.phpfreaks.com/topic/122031-need-help-fixing-this-code/#findComment-629931 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.