guys! I'm in trouble with my MySQL database. When I try to access the fields it doesn't return the exact value. Here is the code.
<?php
  $host = "localhost";
 $user = "******";
 $pass = "******";
 $db = mysql_connect($host, $user, $pass) or die("Unable to connect. Check your connection parameters.");
 mysql_select_db("*****") or die("Unable to select database!");
  $form_username=$_POST["username"];
 $form_password=$_POST["password"];
 $query="
  SELECT username, password FROM users
 ";
 $result=mysql_query($query,$db) or die("Unable to send the query".mysql_error());
 $index=0;
 while($row=mysql_fetch_row($result))
 {
  $username[$index]=row[0];
  $password[$index]=row[1];
  $index++;
 }
 
 for($i=0; $i<=$index; $i++)
 {
  if($form_username==$username[$i]&& $form_password==$password[$i])
  {
   session_start();
   $_SESSION["login"]="OK";
   header("Location: ************");
   die();
  }
 }The if statement inside the for operator returns false for every given value. When I echo every username and password like this:
echo $form_username." ".$username[0]." ".$form_password." ".$password[0]."<br>";
 echo $form_username." ".$username[1]." ".$form_password." ".$password[1]."<br>";
 echo $form_username." ".$username[2]." ".$form_password." ".$password[2]."<br>";It echo me this:
admin r 12345 o
admin r 12345 o
admin r 12345 o
I really don't know where the problem is. I'll really appreciate your help.
 
    