A little problem with if-else

A

Anonymous

Guest
ok try this:
Code:
while ($array = mysql_fetch_array($result))  { 
  if ($user_name == $array['user_name'] && $res_pass == $array['passwrd']) { 
      if ($user_name == 'user1' && $res_pass == '6d9051a4db09be365d25070f9f66d39f') { 
      echo "<br> 
            <table border=\"0\" align =\"center\"> 
            <tbody> 
            <tr> 
            <td>You are authorized.</td> 
            </tr> 
            <tr> 
            <td> 
            <form action=\"epshp.php\" method=\"post\" /> 
            <input type=\"hidden\" name=\"verify_epshp\" value =\"ok\" /> 
            <input type=\"submit\" value=\"Continue\" /> 
            </td></tr></tbody></table>"; 
      } 
      elseif ($user_name == 'user2' && $res_pass == '82c58360b80a0b232e87263f59754103') { 
      echo "<br> 
            <table border=\"0\" align =\"center\"> 
            <tbody> 
            <tr> 
            <td>You are authorized.</td> 
            </tr> 
            <tr> 
            <td> 
            <form action=\"ksshp.php\" method=\"post\" /> 
            <input type=\"hidden\" name=\"verify_ksshp.php\" value =\"ok\" /> 
            <input type=\"submit\" value=\"Continue\" /> 
            </td></tr></tbody></table>"; 
      } 
      elseif ($user_name == 'user3' && $res_pass == 'db0a2a94527aa6d92197245349b106b2') { 
      echo "<br> 
            <table border=\"0\" align =\"center\"> 
            <tbody> 
            <tr> 
            <td>You are authorized.</td> 
            </tr> 
            <tr> 
            <td> 
            <form action=\"ppshp.php\" method=\"post\" /> 
            <input type=\"hidden\" name=\"verify_ppshp.php\" value =\"ok\" /> 
            <input type=\"submit\" value=\"Continue\" /> 
            </td></tr></tbody></table>"; 
      } 
      elseif ($user_name == 'user4' && $res_pass == '230d6f2fbb1b2f868241b805b6f837e7') { 
      echo "<br> 
            <table border=\"0\" align =\"center\"> 
            <tbody> 
            <tr> 
            <td>You are authorized.</td> 
            </tr> 
            <tr> 
            <td> 
            <form action=\"pshp.php\" method=\"post\" /> 
            <input type=\"hidden\" name=\"verify_pshp.php\" value =\"ok\" /> 
            <input type=\"submit\" value=\"Continue\" /> 
            </td></tr></tbody></table>"; 
      }
   }  
   else { 
      echo "<br> 
            <table border=\"0\" align =\"center\"> 
            <tbody> 
            <tr> 
            <td>You are not authorized.</td> 
            </tr> 
            <tr> 
            <td> 
            <input type=\"button\" value=\"Back\" onclick=\"history.go(-1)> 
            </td></tr></tbody></table>"; 
      } 
  
}
 
In your code Ali_baba the last else block doesnt correspond to this id statement:
Code:
if ($user_name == $array['user_name'] && $res_pass == $array['passwrd'])
but to the last elseif... therefore you should move it out from the if block and paste it after: like this:

Code:
while ($array = mysql_fetch_array($result))  {
  if ($user_name == $array['user_name'] && $res_pass == $array['passwrd']) {
      if ($user_name == 'user1' && $res_pass == '6d9051a4db09be365d25070f9f66d39f') {
      echo "<br>
            <table border=\"0\" align =\"center\">
            <tbody>
            <tr>
            <td>You are authorized.</td>
            </tr>
            <tr>
            <td>
            <form action=\"epshp.php\" method=\"post\" />
            <input type=\"hidden\" name=\"verify_epshp\" value =\"ok\" />
            <input type=\"submit\" value=\"Continue\" />
            </td></tr></tbody></table>";
      }
      elseif ($user_name == 'user2' && $res_pass == '82c58360b80a0b232e87263f59754103') {
      echo "<br>
            <table border=\"0\" align =\"center\">
            <tbody>
            <tr>
            <td>You are authorized.</td>
            </tr>
            <tr>
            <td>
            <form action=\"ksshp.php\" method=\"post\" />
            <input type=\"hidden\" name=\"verify_ksshp.php\" value =\"ok\" />
            <input type=\"submit\" value=\"Continue\" />
            </td></tr></tbody></table>";
      }
      elseif ($user_name == 'user3' && $res_pass == 'db0a2a94527aa6d92197245349b106b2') {
      echo "<br>
            <table border=\"0\" align =\"center\">
            <tbody>
            <tr>
            <td>You are authorized.</td>
            </tr>
            <tr>
            <td>
            <form action=\"ppshp.php\" method=\"post\" />
            <input type=\"hidden\" name=\"verify_ppshp.php\" value =\"ok\" />
            <input type=\"submit\" value=\"Continue\" />
            </td></tr></tbody></table>";
      }
      elseif ($user_name == 'user4' && $res_pass == '230d6f2fbb1b2f868241b805b6f837e7') {
      echo "<br>
            <table border=\"0\" align =\"center\">
            <tbody>
            <tr>
            <td>You are authorized.</td>
            </tr>
            <tr>
            <td>
            <form action=\"pshp.php\" method=\"post\" />
            <input type=\"hidden\" name=\"verify_pshp.php\" value =\"ok\" />
            <input type=\"submit\" value=\"Continue\" />
            </td></tr></tbody></table>";
       }   
    }else {
      echo "<br>
            <table border=\"0\" align =\"center\">
            <tbody>
            <tr>
            <td>You are not authorized.</td>
            </tr>
            <tr>
            <td>
            <input type=\"button\" value=\"Back\" onclick=\"history.go(-1)>
            </td></tr></tbody></table>";
    }
}
 
it is expected as you put it in the while loop so if there is(e.g. 4 users in ur db, then you will get the back link 4 time).
 
Back
Top