CMS ultra léger au style oldschool, projet de la communauté Kalaïn Hundin.

login.php 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. session_start();
  3. require_once('config.php');
  4. $username = formulaires($_POST['username']);
  5. $passwd = formulaires($_POST['passwd']);
  6. $passwd=md5($passwd);
  7. if(!$username)
  8. {
  9. header('Location:'.$root_path.'index.php?error=username');
  10. }
  11. if(!$passwd)
  12. {
  13. header('Location:'.$root_path.'index.php?error=pass');
  14. }
  15. //$sqlcount= "SELECT * FROM user WHERE pass='$passwd' AND username='$username'";
  16. $reponse_cores=$dbh->query("SELECT * FROM user WHERE pass='$passwd' AND username='$username'") or die ('error : '.mysql_error());
  17. $count_cores = $reponse_cores->rowCount();
  18. //$count_cores=mysql_num_rows($reponse_cores);
  19. if($count_cores == 0 )
  20. {
  21. header('Location:'.$root_path.'index.php?error=connection');
  22. }
  23. else
  24. {
  25. for ($ligne=0;$ligne<30;$ligne++) //Création d'un identifiant aléatoire
  26. {
  27. @$session.=substr('0123456789AZERTYUIOPMLKJHGFDSQWXCVBN',(rand()%(strlen('0123456789AZERTYUIOPMLKJHGFDSQWXCVBN'))),1);
  28. }
  29. $dbh->query("UPDATE user SET session='$session' WHERE username='$username'") or die ('error : '.mysql_error());
  30. $_SESSION['session'] = "$session"; //création de la session
  31. header('Location:'.$root_path.'user/index.php'); //redirection vers l'index
  32. }
  33. include_once('bottom.php');
  34. ?>