View unanswered posts | View active topics It is currently Thu Dec 14, 2017 12:22 pm



Reply to topic  [ 2 posts ] 
 This code wont work... 
Author Message
Junior Member

Joined: Sun Nov 07, 2004 12:22 am
Posts: 8
Post 
Code:
[LIST]
[/LIST]

$name = $_REQUEST['name'];
$pass = $_REQUEST['pass'];
$passwords = file("usernames.php");
foreach ($passwords as $item) {
list($username,$password) = explode ("|^|", $item);
if(($name == $username) && ($pass == $password)) {
echo "Welcome";
} else {
echo "<center><form name='form1' method='post' action='members.php'>";
echo "Username:<BR>";
echo "<input name='name' type='text' size='40' class='asdf'><BR>";
echo "Password:<BR>";
echo "<input name='pass' type='password' size='40' class='asdf'><BR>";
echo "<input type='submit' name='Submit' value='Enter' class='asdf'>";
echo "</form></center>"; // Middle Text End
}


Why wont this work?

_________________
[url=\'http://www.zerographics.org/forums\']http://www.zerographics.org/forums[/url]


Sat Jan 08, 2005 3:54 pm
Report this post
Profile
Junior Member

Joined: Tue Jan 04, 2005 10:50 am
Posts: 17
Post 
You are missing a } closing bracket. Not sure where they intended it to go. Rather brute force way of getting authorized.

Code:
<?
$name = $_REQUEST['name'];
$pass = $_REQUEST['pass'];
$passwords = file("usernames.php");

foreach ($passwords as $item) {
   list($username,$password) = explode ("|^|", $item);
if(($name == $username) && ($pass == $password)) {
   echo "Welcome";
} else {
   echo "<center><form name='form1' method='post' action='members.php>";
   echo "Username:<BR>";
   echo "<input name='name' type='text' size='40' class='asdf'><BR>";
   echo "Password:<BR>";
   echo "<input name='pass' type='password' size='40' class='asdf'><BR>";
   echo "<input type='submit' name='Submit' value='Enter' class='asdf'>";
   echo "</form></center>"; // Middle Text End
}
}
?>


The problem with this code is if you place the } after the code in the for() statement you will only get access if you have the last user name. And if you have the code how I have it, the username and password form fields will repeat for as many users as you have in the file. I would not use this code though to be honest.


Sat Jan 08, 2005 10:05 pm
Report this post
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.