Jump to content

need help fixing this code


RadiationHazard

Recommended Posts

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

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!!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.