Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] sesja utracona
AsenClave
post
Post #1





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 5.10.2010

Ostrzeżenie: (0%)
-----


Nie wiem, dlaczego tak sie zachowuje :/

Testy prosze przeprowadzac pod tym adresem (jest tez zaladowany phpinfo(); ) http://195.211.2.7/

Konto probne: login(test) passwd(test)

A tu kod strony:
  1. <?php
  2.  
  3. echo '<div>Test kroju czcionki</div>';
  4.  
  5. mysql_connect( '/hide/', '/hide/', '/hide/ ' );
  6. mysql_select_db( '/hide/' );
  7.  
  8. if ( $_SESSION['auth'] != 1 ) $_SESSION['auth'] = false;
  9.  
  10. if ( strlen( $_POST['login'] ) && strlen( $_POST['passwd'] ) ) login( $_POST['login'], $_POST['passwd'] );
  11.  
  12. function login( $login, $passwd ) {
  13. $login = md5( $login );
  14. $passwd = md5( $passwd );
  15.  
  16. $query = mysql_query( "SELECT * FROM `account` WHERE `login`='$login' AND `passwd`='$passwd' LIMIT 1" );
  17.  
  18. if ( $mysql_num_rows( $query ) ) {
  19. $row = mysql_fetch_array( $query );
  20.  
  21. $_SESSION['auth'] = true;
  22.  
  23. $_SESSION['account-id'] = $row['id'];
  24. $_SESSION['account-name'] = $row['name'];
  25. $_SESSION['account-email'] = $row['email'];
  26. }
  27. }
  28.  
  29. /*
  30. $login = md5( 'test' );
  31. $passwd = md5( 'test' );
  32. $name = 'Test';
  33. $email = 'test@test.test';
  34. $data = time();
  35.  
  36. mysql_query( "INSERT INTO `account` VALUES ( NULL, '$login', '$passwd', '$name', '$email', '$data' )" );
  37. */
  38. ?>
  39. <meta http-equiv="content-type" content="text/html; charset=utf-8">
  40. <style type="text/css">
  41. * { font-family: "DejaVu Sans", Verdana; font-size: 13px; color: #777777; }
  42.  
  43. input, textarea { border: 1px solid #dddddd; background-color: #eeeeee; }
  44. form { margin: 0px; padding: 0px; }
  45.  
  46. .package { width: 780px; margin: 0px auto; }
  47. .login { width: 140px; margin: 0px auto; }
  48.  
  49. .align-right { text-align: right; }
  50. .align-center { text-align: center; }
  51.  
  52. .width-90 { width: 90%; }
  53.  
  54. .move-little-lower { margin-top: 2px; }
  55. </style>
  56. <div>Test kroju czcionki</div>
  57. <div class="package">
  58. <?php
  59. if ( ! $_SESSION['auth'] ) include( 'login.htm' );
  60. else
  61. echo 'ok.';
  62.  
  63. ?>
  64. </div>


  1. <div class="login">
  2. <form action="index.php" method="post">
  3. <div class="">Login:</div>
  4. <div class="align-right"><input class="align-center width-90" type="text" name="login" value="" /></div>
  5. <div class="">Password:</div>
  6. <div class="align-right"><input class="align-center width-90" type="password" name="passwd" value="" /></div>
  7. <div class="align-right"><input class="move-little-lower" type="submit" value="Accept" /></div>
  8. </form>
  9. </div>
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.08.2025 - 17:38