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

login.php 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. $reponse_cores=mysql_query("SELECT * FROM user WHERE pass='$passwd' AND username='$username'") or die ('error : '.mysql_error());
  16. $count_cores=mysql_num_rows($reponse_cores);
  17. if($count_cores == 0 )
  18. {
  19. header('Location:'.$root_path.'index.php?error=connection');
  20. }
  21. else
  22. {
  23. for ($ligne=0;$ligne<30;$ligne++) //Création d'un identifiant aléatoire
  24. {
  25. @$session.=substr('0123456789AZERTYUIOPMLKJHGFDSQWXCVBN',(rand()%(strlen('0123456789AZERTYUIOPMLKJHGFDSQWXCVBN'))),1);
  26. }
  27. mysql_query("UPDATE user SET session='$session' WHERE username='$username'") or die ('error : '.mysql_error());
  28. $_SESSION['session'] = "$session"; //création de la session
  29. header('Location:'.$root_path.'user/index.php'); //redirection vers l'index
  30. }
  31. include_once('bottom.php');
  32. ?>