Advertisement
Guest User

Untitled

a guest
Jun 19th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. <?php //Start the Session
  2. session_start();
  3. require('connect.php');
  4. //3. If the form is submitted or not.
  5. //3.1 If the form is submitted
  6. if (isset($_POST['form-username']) and isset($_POST['form-password'])){
  7. //3.1.1 Assigning posted values to variables.
  8. $username = $_POST['form-username'];
  9. $password = $_POST['form-password'];
  10. }else{
  11. echo "Nu ai introdus username sau parola.";
  12. }
  13.  
  14. $tip = "";
  15.  
  16. //3.1.2 Checking the values are existing in the database or not
  17. $query = "SELECT * FROM conturi WHERE username='$username' and password='$password'";
  18.  
  19. $result = mysqli_query($connection, $query) or die(mysqli_error($connection));
  20.  
  21. if (mysqli_num_rows($result) > 0) {
  22. // output data of each row
  23. while($row = mysqli_fetch_assoc($result)) {
  24. $id = $row['id'];
  25. $tip = $row["tip"];
  26. }
  27. }else{
  28. echo "Datele de logare sunt invalide.";
  29. }
  30.  
  31. if($tip == 'admin'){
  32. $_SESSION['loggedIn'] = true;
  33. header("location:profile_admin.php?id=$id");
  34. }else if($tip == 'user'){
  35. $_SESSION['loggedIn'] = true;
  36. header("location:profile.php?id=$id");
  37.  
  38. }
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement