Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Automatyczne pzekierowanie po zalogowaniu
--ewelina--
post
Post #1





Goście







Witam

prosze o pomoc
mam skrypcik logowania ale niewiem co dodac aby automatycznie po zalogowaniu pzekierowało usera do jego profilu.
prubowałam dodac header("profile.php?id='.$user['id'].'");
ale nic z tego.
prubowałam echo "<script>window.location.href="profile.php?id='.$user['id'].";</script> i nic

  1. <?php
  2.  
  3. require 'header.php';
  4. require 'include/config.php';
  5. require_once 'user.class.php';
  6. ?>
  7. <?php
  8. if (user::isLogged()) {
  9.  
  10. $user = user::getData('', '');
  11.  
  12. echo '<center><font color="#00FF00">Jesteś zalogowany, witaj '.$user['login'].'!</font></center><center><font color="#00FF00">Możesz zobaczyć swój <a href="profile.php?id='.$user['id'].'">profil</a> albo się <a href="logout.php">wylogować</a></font></center><br>
  13. ';
  14. }
  15.  
  16. else {
  17.  
  18. echo '<div align="center"<center><p><font color="#CCCCCC">Nie jesteś zalogowany. <img src="images/niezal.png" width="30" height="30" /><br /><a href="login.php">Zaloguj</a> się lub <a href="register.php">zarejestruj</a> jeżeli jeszcze nie masz konta.</font></p></center></div>
  19. ';
  20. }
  21. require 'include/menu.tpl';
  22. require 'footer.php';
  23.  
  24. ?>
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
-eewelina-
post
Post #2





Goście







no ok loguj i pokazuje zmieniłam to w tym user.class
ale dalej nie wyświetla danych jak mam taka tabele to nie pokazuje
tam gdzie jes $profile['login'] i inne to nic sie nie wyswietla a wczesniej jak było na id to było ok
  1. <div class="div"><center><font color="#999999"><h3>Profil uzytkownika '.$profile['login'].'</h3></font></center></div>
  2. <table class="tableq" cellpadding="10" cellspacing="0">
  3. <tr></tr>
  4. <tr>
  5. <td width="200" align="center" class="td1"><font color="#CCCCCC"><b>Nick:</b></font></td>
  6. <td align="center" class="td3"><font color="#CCCCCC">'.$profile['login'].'</font></td>
  7. <tr>
  8. <td width="200" align="center" class="td1"><font color="#CCCCCC"><b>Email:</b></font></td>
  9. <td align="center" class="td3"><font color="#CCCCCC">'.$profile['email'].'</font></td>
  10. </tr>
  11. <tr>
  12. <td width="200" align="center" class="td1"><font color="#CCCCCC"><b>Imie:</b></font></td>
  13. <td align="center" class="td3"><font color="#CCCCCC">'.$profile['imie'].'</font></td>
  14. </tr>
  15. <tr>
  16. <td width="200" align="center" class="td1"><font color="#CCCCCC"><b>Nazwisko:</b></font></td>
  17. <td align="center" class="td3"><font color="#CCCCCC">'.$profile['nazwisko'].'</font></td>
  18. </tr>
  19. <tr>
  20. <td width="200" align="center" class="td1"><font color="#CCCCCC"><b>Miasto:</b></font></td>
  21. <td align="center" class="td3"><font color="#CCCCCC">'.$profile['miasto'].'</font></td>
  22. </tr>
  23. <tr>
  24. <td width="200" align="center" class="td1"><font color="#CCCCCC"><b>Numer gg:</b></font></td>
  25. <td align="center" class="td3"><font color="#CCCCCC">'.$profile['gg'].'</font></td>
  26. </tr>
  27. <tr>
  28. <td width="200" align="center" class="td1"><font color="#CCCCCC"><b>Skype:</b></font></td>
  29. <td align="center" class="td3" ><font color="#CCCCCC">'.$profile['skype'].'</font></td>
  30. </tr>
  31. <tr>
  32. <td align="center"><a href="editprofile.php">edztuj</a></td>
  33. </table>';

podaje ci
skrypt profile
  1. <?php header('Content-type: text/html; charset=utf-8'); ?>
  2. <?php
  3. /**
  4.  * Profil
  5.  * @author Sobak
  6.  * @package User System
  7.  */
  8.  
  9. require 'header.php';
  10. require 'include/config.php';
  11. require_once 'user.class.php';
  12.  
  13. if (!user::isLogged()) {
  14. echo '<center><font color="#ff0000"><p class="error">Przykro nam, ale ta strona jest dostepna tylko dla zalogowanych.</p></font></center>';
  15. }
  16.  
  17. else {
  18. $login = $_GET['login'];
  19.  
  20. */
  21. $userExist = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM users WHERE login = '$login'"));
  22.  
  23. if ($userExist[0] == 0) {
  24. die ('<center><font color="#ff0000"><p>Przykro nam, ale uzytkownik o podanym identyfikatorze nie istnieje.</p></font></center>');
  25. }
  26.  
  27. $profile = user::getDataById ($login);
  28.  
  29. echo '<style>
  30. .div
  31. {
  32. width:500px;
  33. height:30px;
  34. margin:0 auto;
  35. background-image:url(include/styles/default/images/fondotduser.png);
  36. border-radius:10px 10px 0px 0px ;
  37. }
  38. .tableq
  39. {
  40. width:500px;
  41. height: auto;
  42. background-color:#CCDBF2;
  43. margin:0 auto;
  44. border-radius:0px 0px 10px 10px ;
  45. box-shadow: 0 0 30px 5px #900 ;
  46. background-image:url(include/styles/default/images/fondoprofil.png);
  47. }
  48. .td1
  49. {
  50.  
  51. border-radius:0px 0px 0px 0px ;
  52. border-bottom:1px #000000 groove;
  53. border-right:2px #99CC00 ridge;
  54.  
  55. }
  56. .td2
  57. {
  58.  
  59. border-radius:0px 0px 0px 10px ;
  60. border-right:2px #99CC00 ridge;
  61. }
  62. .td3
  63. {
  64. border-bottom:1px #000000 groove;
  65. }
  66. .boton
  67. {
  68. width:100px;
  69. height:30px;
  70. background-image:url(include/styles/default/images/boton.png);
  71. border-radius:5px 5px 5px 5px;
  72.  
  73. }
  74. </style>
  75. <div class="div"><center><font color="#999999"><h3>Profil uzytkownika '.$profile['login'].'</h3></font></center></div>
  76. <table class="tableq" cellpadding="10" cellspacing="0">
  77. <tr></tr>
  78. <tr>
  79. <td width="200" align="center" class="td1"><font color="#CCCCCC"><b>Nick:</b></font></td>
  80. <td align="center" class="td3"><font color="#CCCCCC">'.$profile['login'].'</font></td>
  81. <tr>
  82. <td width="200" align="center" class="td1"><font color="#CCCCCC"><b>Email:</b></font></td>
  83. <td align="center" class="td3"><font color="#CCCCCC">'.$profile['email'].'</font></td>
  84. </tr>
  85. <tr>
  86. <td width="200" align="center" class="td1"><font color="#CCCCCC"><b>Imie:</b></font></td>
  87. <td align="center" class="td3"><font color="#CCCCCC">'.$profile['imie'].'</font></td>
  88. </tr>
  89. <tr>
  90. <td width="200" align="center" class="td1"><font color="#CCCCCC"><b>Nazwisko:</b></font></td>
  91. <td align="center" class="td3"><font color="#CCCCCC">'.$profile['nazwisko'].'</font></td>
  92. </tr>
  93. <tr>
  94. <td width="200" align="center" class="td1"><font color="#CCCCCC"><b>Miasto:</b></font></td>
  95. <td align="center" class="td3"><font color="#CCCCCC">'.$profile['miasto'].'</font></td>
  96. </tr>
  97. <tr>
  98. <td width="200" align="center" class="td1"><font color="#CCCCCC"><b>Numer gg:</b></font></td>
  99. <td align="center" class="td3"><font color="#CCCCCC">'.$profile['gg'].'</font></td>
  100. </tr>
  101. <tr>
  102. <td width="200" align="center" class="td1"><font color="#CCCCCC"><b>Skype:</b></font></td>
  103. <td align="center" class="td3" ><font color="#CCCCCC">'.$profile['skype'].'</font></td>
  104. </tr>
  105. <tr>
  106. <td align="center"><a href="editprofile.php">edztuj</a></td>
  107. </table>';
  108.  
  109.  
  110. }
  111.  
  112. require 'footer.php';
  113. ?>


i skrypt user.clas
  1. <?php
  2.  
  3. class user {
  4.  
  5. public static $user = array();
  6.  
  7. public function getData ($login, $pass) {
  8. if ($login == '') $login = $_SESSION['login'];
  9. if ($pass == '') $pass = $_SESSION['pass'];
  10.  
  11. self::$user = mysql_fetch_array(mysql_query("SELECT * FROM users WHERE login='$login' AND pass='$pass' LIMIT 1;"));
  12. return self::$user;
  13. }
  14.  
  15.  
  16. public function getDataById ($login) {
  17. $user = mysql_fetch_array(mysql_query("SELECT * FROM users WHERE id='$id' LIMIT 1;"));
  18. return $user;
  19. }
  20.  
  21. public function isLogged () {
  22. if (empty($_SESSION['login']) || empty($_SESSION['pass'])) {
  23. return false;
  24. }
  25.  
  26. else {
  27. return true;
  28. }
  29. }
  30.  
  31. public function passSalter ($pass) {
  32. $pass = '$@@#$#@$'.$pass.'q2#$3$%##@';
  33. return md5($pass);
  34. }
  35.  
  36. }


ja juz niewiem gdzie jest ten błąd
Go to the top of the page
+Quote Post

Posty w temacie
- -ewelina-   [PHP]Automatyczne pzekierowanie po zalogowaniu   4.07.2012, 18:15:57
- - CuteOne   [PHP] pobierz, plaintext header("Locatio...   4.07.2012, 18:28:57
- - Gość   Sprobuj [PHP] pobierz, plaintext header('loca...   4.07.2012, 18:29:25
- - -ewelina-   witam dzieki wszystko działa. a jeszcze jedno dl...   5.07.2012, 07:44:42
- - Shido   Ponieważ uzyskujesz dane z poprzez id, musisz prze...   5.07.2012, 07:57:44
- - Gość   [PHP] pobierz, plaintext header('location: pro...   5.07.2012, 08:00:57
|- - Lorum3   Cytat(Gość @ 5.07.2012, 09:00:57 ) [P...   5.07.2012, 08:31:09
- - -ewelina-   dzieki działa a jeszcze moze macie jakiegos linka...   5.07.2012, 10:06:43
- - amii   Tu masz omówioną integrację ze stroną implementują...   5.07.2012, 10:52:29
- - -ewelina-   znowu problem nmieniłam to z tym id dodałam login...   5.07.2012, 11:02:50
- - Shido   [PHP] pobierz, plaintext $profile = user::getData...   5.07.2012, 11:08:52
- - eewelina   no ok loguj i pokazuje zmieniłam to w tym user.cla...   5.07.2012, 12:07:58
- - Shido   user.class.php [PHP] pobierz, plaintext public fun...   5.07.2012, 12:24:24
- - -ewelina-   witam jeszcze moze powieci mi dlaczego jak zalog...   6.07.2012, 11:02:00
- - redeemer   [PHP] pobierz, plaintext if (!user::isLogged...   6.07.2012, 11:06:33
- - -ewelina-   to podpowiedz jak to zmienic aby było bezpieczniej   6.07.2012, 12:44:43
- - -ewelina-   jak zmieniłam (!user::isLogged()) na (!...   6.07.2012, 12:48:58
- - -ewelina-   jeszcze takie małe pytanko jak skonstruawac baze ...   6.07.2012, 13:10:35
- - Shido   Tabela userów, gdzie musi być id np: id | nick | p...   6.07.2012, 13:31:44
- - -ewelina-   ok co do bazy to jeszcze poprubuje puzniej ale z ...   6.07.2012, 13:57:14
- - -ewelina-   a co do tej bazy np jesli user doda 5 adresuów ema...   6.07.2012, 14:00:02
- - Shido   z bazą robisz to w taki sposób: Formularz do doda...   6.07.2012, 14:05:44
- - -ewelina-   dzieki troszke sie pomecze a z tym formulazem moz...   6.07.2012, 14:18:31
- - -ewelina-   prosze pomuzcie z tym formularzem dlaczego jak pze...   6.07.2012, 16:00:54
- - Gość   witam mam problem ze skryptem . Po zalogowaniu ni...   10.07.2012, 08:41:22


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

 



RSS Aktualny czas: 6.12.2025 - 15:11