Page 1 of 1

[SOLVED]Viewing all member's username and passwords!

Posted: Sat Jan 10, 2004 3:20 pm
by Straterra
I have a database with a view users, and I am trying to add a feature so that I can view all passwords..I have this code, but it does some really funky things. Please help me fix it. It shows one user, but shows every password with that user

EXAMPLE

straterra : moo
straterra : thisisanotherpw
straterra : foo
mofo : moo
mofo : thisisanotherpw
mofo : foo

Code: Select all

<?php
include('banned.php');
?>
<?php
$tester = isset($_SESSION["username"]);
if ( $tester == false ) {
header("Location: loginform.php");
} else {
$user = $_SESSION["username"];
if ( $user == "straterra" ) {
$dbname = 'eckbios';
if ($db = sqlite_open($dbname, 0666, $sqliteerror)){
$result = (sqlite_query($db, "SELECT username from logintable ORDER BY username"));
while ($row=sqlite_fetch_array($result)) {
$result2 = (sqlite_query($db, "SELECT password from logintable ORDER BY username"));
while ($row2=sqlite_fetch_array($result2)) {
echo $row['username']." : ".$row2['password']."<br>";
}
}
}
} else {
header("Location: loginform.php");
}
}
?>

Posted: Sat Jan 10, 2004 3:43 pm
by Straterra
I have fixed this myself. Here is the code that works! ^_^

Code: Select all

<?php
include('banned.php');
?>
<?php
$tester = isset($_SESSION["username"]);
if ( $tester == false ) {
header("Location: loginform.php");
} else {
$user = $_SESSION["username"];
if ( $user == "straterra" ) {
$dbname = 'eckbios';
if ($db = sqlite_open($dbname, 0666, $sqliteerror)){
$result = (sqlite_query($db, "SELECT username from logintable ORDER BY username"));
while ($row=sqlite_fetch_array($result)) {
$moo = $row['username'];
$result2 = sqlite_query($db, "select password from logintable where username = '$moo'");
$result2 = sqlite_fetch_array($result2);
echo $row['username']." : ".$result2['password']."<br>";
}
}
} else {
header("Location: loginform.php");
}
}
?>