Advertisement
Guest User

Untitled

a guest
May 17th, 2016
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. if(isset($_POST['submit'])){
  5. $servername="localhost";
  6. $username="root";
  7. $password="";
  8. $dbname="orphelins";
  9.  
  10. $nom_d_utilisateur=$mot_de_pass=$passmd5='';
  11.  
  12. $conn= mysqli_connect($servername,$username,$password,$dbname);
  13.  
  14. if (mysqli_connect_errno()) {
  15. printf("Connect failed: %s\n", mysqli_connect_error());
  16. exit();
  17. }
  18.  
  19. if ($_SERVER["REQUEST_METHOD"] == "POST") {
  20. $nom_d_utilisateur= $_POST["nom_d_utilisateur"];
  21. $mot_de_pass= $_POST["mot_de_pass"];
  22.  
  23. }
  24. $passmd5=md5($mot_de_pass);
  25.  
  26.  
  27. $sql= "SELECT nom_d_utilisateur,mot_de_pass FROM user WHERE nom_d_utilisateur ='$nom_d_utilisateur' AND mot_de_pass='$mot_de_pass' ";
  28. $result = mysqli_query($conn, $sql);
  29.  
  30. if ($result) {
  31.  
  32. }else{
  33. die("database query failed".mysqli_error($conn));
  34. }
  35.  
  36.  
  37. if(mysqli_num_rows($result) > 0){
  38. $row = mysqli_fetch_assoc($result);
  39. session_start();
  40. $_SESSION['nom_d_utilisateur'] = $row["nom_d_utilisateur"];
  41. $_SESSION['mot_de_pass'] = $row["mot_de_pass"];
  42. $_SESSION['logged'] = TRUE;
  43. mysqli_close($conn);
  44. header("Location: admin.php"); // Modify to go to the page you would like
  45. exit;
  46. }
  47. else{
  48.  
  49. header("Location: adherent.php");
  50. exit;
  51. }
  52.  
  53. }
  54. else{ //If the form button wasn't submitted go to the index page, or login page
  55. header("Location: index.php");
  56. exit;
  57.  
  58. }
  59. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement