Blame view

htdocs/documents/login.php 761 Bytes
c10d2abc   rcavalie   ajout fichiers se...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
  <?php
  
  session_start();
  require_once 'include/DB_Functions.php';
  $db = new DB_Functions();
  
  if (isset($_POST['username']) && isset($_POST['password'])) {
  
      // receiving the post params
      $username = $_POST['username'];
      $password = $_POST['password'];
  
      // get the user by username and password
      $user = $db->getUserByLoginAndPassword($username, $password);
  
      if ($user != false) {
        //use is found
          $_SESSION['name'] = $user['name'];
  	    header('Location: workArea.php');
      } else {
          // user is not found with the credentials
          die ("username credentials are wrong. Please try again!");
      }
  } else {
      // required post params is missing
      die ("Required parameters username or password is missing!");
    
  }
  ?>