Guest User

Untitled

a guest
Sep 2nd, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. <?php
  2. class Oturum
  3. {
  4.  
  5. public $name;
  6. public $other=array();
  7.  
  8. public function __construct()
  9. {
  10.  
  11. session_start();
  12. }
  13.  
  14. public function check_user($username="Kayhan",$password="Ozturk")
  15. {
  16. mysql_connect('localhost','root','') or die(mysql_error());
  17. mysql_select_db('cinema') or die(mysql_error());
  18. $query="select * from users where user_name='$username' and user_pass='$password'";
  19. $result=mysql_query($query);
  20. print_r($result);
  21. if(mysql_num_rows($result)>0)
  22. {
  23. $display=mysql_fetch_array($result);
  24. $_SESSION['user_name']=$display['user_name'];
  25. $_SESSION['pass']=$display['user_pass'];
  26. return $_SESSION;
  27. }
  28. else
  29. {
  30. echo 'Boyle bir kullanıcı yoktur!';
  31. }
  32. }
  33. public function display_message()
  34. {
  35. if(!$_SESSION)
  36. echo 'Siktirgit oturum bile acmamıssın sen daha amcık';
  37.  
  38. foreach($_SESSION as $key=>$value)
  39. {
  40. echo 'Hosgeldin '.' '.$key.'<br />'.'Sifren ise soyle:'.' '.$value;
  41. }
  42. }
  43.  
  44. function logout($conditional=false)
  45. {
  46. if($conditional!=false)
  47. {
  48. echo 'Kapatılamadı adamım sen izin vermedin zaten';
  49. }
  50. else
  51. {
  52. unset($_SESSION);
  53. session_destroy();
  54. echo 'Cıkıs yaptınız ';
  55. }
  56. }
  57.  
  58. }
  59.  
  60. $deneme=new Oturum();
  61.  
  62. $deneme->check_user('Kayhan','Ozturk');
  63. $deneme->display_message();
  64. $deneme->logout();
  65. ?>
Add Comment
Please, Sign In to add comment