SHOW:
|
|
- or go back to the newest paste.
| 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;//מונה |
| 15 | + | if ($stmt=$mysqli->prepare("SELECT user,password FROM user_admin WHERE user= ?"))
|
| 16 | {
| |
| 17 | - | //הכנסת כל התוצאות אל המערך |
| 17 | + | $stmt->bind_param('s', $user_from_login);
|
| 18 | - | $user_array=array(); |
| 18 | + | |
| 19 | - | $password_array=array(); |
| 19 | + | |
| 20 | } | |
| 21 | ||
| 22 | ||
| 23 | ||
| 24 | ||
| 25 | if(!$stmt->fetch()) {
| |
| 26 | - | if ($stmt=$mysqli->prepare("SELECT user,password FROM user_admin "))
|
| 26 | + | // No such user |
| 27 | header("HTTP/1.1 401 Unauthorized");
| |
| 28 | die(); | |
| 29 | } | |
| 30 | ||
| 31 | if($passwordFromDB !== $password_from_login) {
| |
| 32 | //Bad password | |
| 33 | header("HTTP/1.1 401 Unauthorized");
| |
| 34 | die(); | |
| 35 | - | //הכנסת כל התוצאות אל המערך תוך כדי צמצום רווחים וקידום המונה |
| 35 | + | |
| 36 | - | while ($stmt->fetch()) |
| 36 | + | |
| 37 | $stmt->close(); | |
| 38 | - | trim($userFromDB); |
| 38 | + | |
| 39 | - | trim($passwordFromDB); |
| 39 | + | header("Location:show_users.php");
|
| 40 | exit(); | |
| 41 | - | array_push($user_array, $userFromDB); |
| 41 | + | |
| 42 | - | array_push($password_array, $passwordFromDB); |
| 42 | + |