refaelgold

Untitled

Jun 29th, 2012
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.42 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. /*******************************************/
  5. /************ולידציה של מנהלי אתר***********/
  6. /*******************************************/
  7.  
  8. require 'connector.php';
  9.  
  10. //השגת אלמנטיפ מטופס המילוי של כניסת המנהלים
  11. $user_from_login=$_POST['user'];
  12. $password_from_login=$_POST['password'];
  13.  
  14.  
  15. $innner_counter=0;//מונה
  16.  
  17. //הכנסת כל התוצאות אל המערך
  18. $user_array=array();
  19. $password_array=array();
  20.  
  21.  
  22.  
  23.  
  24.  
  25. //שליפה של כל הנתונים מתוך מבנה הנתונים על מנת לבצע השוואה
  26. if ($stmt=$mysqli->prepare("SELECT user,password FROM user_admin "))
  27. {
  28.     $stmt->execute();
  29.     $stmt->bind_result($userFromDB,$passwordFromDB);
  30. }
  31.  
  32.  
  33.  
  34.  
  35. //הכנסת כל התוצאות אל המערך תוך כדי צמצום רווחים וקידום המונה 
  36. while ($stmt->fetch())
  37. {
  38.     trim($userFromDB);
  39.     trim($passwordFromDB);
  40.  
  41.     array_push($user_array, $userFromDB);
  42.     array_push($password_array, $passwordFromDB);
  43.    
  44.     $innner_counter++;
  45. }
  46.    
  47. $stmt->close();
  48.  
  49. for ($i = 0; $i < $innner_counter; $i++)
  50.     {
  51.    
  52.         if (($password_from_login===$password_array[$i]) && ($password_from_login===$password_array[$i]))
  53.             {
  54.                 header("Location:show_users.php");
  55.                 exit();
  56.             }
  57.     }
  58.    
  59.     //password or user are incorrent - in this case the client will redirect to other page
  60.     header("HTTP/1.1 401 Unauthorized");   
  61.     exit();
  62. ?>
Advertisement
Add Comment
Please, Sign In to add comment