Hello
I have create a login formula where members in a database can change information about themselves - but they cannot change information about the other members.
But it does not work. It seems like the loop only runs one time, because only the first member in the database logs in perfectly. If I add "WHERE name='jan'" to the query "SELECT * FROM members", I am let in, but no one else and vice versa. Can anybody tell me what I have done wrong?
Greatings from Jan
Function ChangeInfo(){
global $id, $username, $password, $name, $lastname;
$search = "UPDATE members SET username='$username', password='$password', name='$name', lastname='$lastname' WHERE id='$id'";
$result = mysql_query($search) or die;
}
if (!isset($password)&&!isset($username)){
print "<form method=\"post\" action=\"$PHP_SELF\">";
print "<table><tr><td>";
print "Username: <input name=\"username\" type=\"text\"></td></tr>";
print "<TR><TD>";
print "Password : <input name=\"password\" type=\"password\"><br><br>";
print "<input type=\"submit\" value=\"Login\"></center></td></tr></table></form>";
}else{
$search = "SELECT * FROM members";
$result = mysql_query($search) or die ;
while($row=mysql_fetch_array ($result)){
if ($password==$row[password] && $username==$row[username]||$id){
if ($aktion=="correct"){
ChangeInfo();
print "<BR><BR><BR>";
print "<H2><CENTER>";
print "Hello $name<BR>";
print "You have changed information to the database<BR>";
print "Log out:";
print "<A HREF='index.php'>Click</A><BR>";
print "See result:";
print "<A HREF='../members/members.php?id=$id'>Click</A><BR>";
print "</CENTER></H2>";
break;
}else{
ChangeInfo();
$id=$row[id];
$username=$row[username];
$password=$row[password];
$name=$row[name];
$lastname=$row[lastname];
if($id){
print "<form method=\"post\" action=\"$PHP_SELF?\">";
print "<INPUT TYPE=\"hidden\" NAME=\"id\" VALUE=\"$id\">\n";
print "<INPUT TYPE=\"hidden\" NAME=\"action\" VALUE=\"correct\">\n";
print "<TABLE border=2 cellspacing=3 cellpadding=2 bgcolor=\"#FCDB69\">";
#Fill in username and password
print "<TR><TD width=200 align=right valign=top>Username</TD>";
print "<TD><input type=\"text\" size=10 name=\"username\" value=\"$username\">";
print " Password: ";
print "<input type=\"text\" size=10 name=\"password\" value=\"$password\">";
print "</TD></TR>";
#Fill in name an lastname
print "<TR><TD align=right>Name:</TD><TD><input type=\"text\" size=50 name=name value=\"$name\"></TD></TR>";
print "<TR><TD align=right>Lastname:</TD><TD><input type=\"text\" size=50 name=lastname value=\"$lastname\"></TD></TR></TABLE>";
print "<BR>";
print "<BR>";
#Submit
print "<input type=submit name=new value='Submit'>";
print " ";
print "<input type=reset name=reset value='Reset'> <BR>";
print "</form>";}
break;}
}else {
print "Login failed";
break;}
}}
?>