Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [MySQL][PHP]Problem ze skryptem z logowaniem
Forum PHP.pl > Forum > Przedszkole
alfemix
Witam!
Logowanie działa, ale profil użytkownika nie działa. A dokładniej:
Pokazuje że niema użytkownika o takim id. Jestem zalogowany, w bazie danych jest id, jest użytkownik, ale profil nie działa.
Skrypt do profilu:
  1. <?php
  2. /**
  3.  * Profil
  4.  * @author Sobak
  5.  * @package User System
  6.  */
  7.  
  8. require 'header.php'; // Dołącz początkowy kod HTML
  9. require 'config.php'; // Dołącz plik konfiguracyjny i połączenie z bazą
  10. require_once 'user.class.php';
  11.  
  12. /**
  13.  * Tylko dla zalogowanych użytkowników
  14.  */
  15. if (!user::isLogged()) {
  16. echo '<p class="error">Przykro nam, ale ta strona jest dostępna tylko dla zalogowanych użytkowników.</p>';
  17. }
  18.  
  19. else {
  20. $id = $_GET['id'];
  21.  
  22. /**
  23.   * Sprawdź czy użytkownik o podanym ID istnieje
  24.   */
  25. $userExist = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM users WHERE id = '$id'"));
  26.  
  27. // Użytkownik nie istnieje
  28. if ($userExist[0] == 0) {
  29. die ('<p>Przykro nam, ale użytkownik o podanym identyfikatorze nie istnieje.</p>');
  30. }
  31.  
  32. /**
  33.   * Użytkownik istnieje, tak więc pokaż jego profil
  34.   */
  35.  
  36. // Zapisz dane użytkownika o podanym ID, do zmiennej $profile
  37. $profile = user::getDataById ($id);
  38.  
  39. echo '<h1>Profil użytkownika '.$profile['login'].'</h1>';
  40.  
  41. echo '<b>Nick:</b> '.$profile['login'].'<br />';
  42. echo '<b>Email:</b> '.$profile['email'].'<br />';
  43.  
  44. }
  45.  
  46. require 'footer.php'; // Dołącz końcowy kod HTML
  47.  
  48. ?>


Baza danych jest ok. Tu jest cały skrypt config, itd
http://www.forumweb.pl/gotowe-komponenty-w...ia-profil,65408

Proszę o pomoc
Kshyhoo
  1. $id = $_GET['id'];

A to gdzie do linka idzie?
Comandeer
A na samej górze:
Cytat
Uwaga (05.01.15)! Nowa wersja skryptu w końcu się wykluła.

Nie wiem czemu ludzie uparcie korzystają z tej starej wersji…
alfemix
Zainstalowałem nowszą wersję i taki komunikat:
Parse error: syntax error, unexpected '{' in /home/alfemix/public_html/cs/includes/password.php on line 10

no i tak tu mamay część pliku password.php :

  1. <?php
  2. /**
  3.  * A Compatibility library with PHP 5.5's simplified password hashing API.
  4.  *
  5.  * @author Anthony Ferrara <ircmaxell@php.net>
  6.  * @license <a href="http://www.opensource.org/licenses/mit-license.html" target="_blank">http://www.opensource.org/licenses/mit-license.html</a> MIT License
  7.  * @copyright 2012 The Authors
  8.  */
  9.  
  10. namespace {
  11.  
  12. if (!defined('PASSWORD_DEFAULT')) {
  13.  
  14. define('PASSWORD_BCRYPT', 1);
  15. define('PASSWORD_DEFAULT', PASSWORD_BCRYPT);
  16.  
  17. /**
  18.   * Hash the password using the specified algorithm
  19.   *
  20.   * @param string $password The password to hash
  21.   * @param int $algo The algorithm to use (Defined by PASSWORD_* constants)
  22.   * @param array $options The options for the algorithm to use
  23.   *
  24.   * @return string|false The hashed password, or false on error.
  25.   */
  26. function password_hash($password, $algo, array $options = array()) {
  27. if (!function_exists('crypt')) {
  28. trigger_error("Crypt must be loaded for password_hash to function", E_USER_WARNING);
  29. return null;
  30. }
  31. if (!is_string($password)) {
  32. trigger_error("password_hash(): Password must be a string", E_USER_WARNING);
  33. return null;
  34. }
  35. if (!is_int($algo)) {
  36. trigger_error("password_hash() expects parameter 2 to be long, " . gettype($algo) . " given", E_USER_WARNING);
  37. return null;
  38. }
  39. $resultLength = 0;
  40. switch ($algo) {
  41. case PASSWORD_BCRYPT:
  42. // Note that this is a C constant, but not exposed to PHP, so we don't define it here.
  43. $cost = 10;
  44. if (isset($options['cost'])) {
  45. ...
Comandeer
Jaką masz wersję PHP? Bo wygląda, że starszą niż 5.3.
alfemix
Rzeczywiście, zmiana wersji php pomogła!
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.