Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [MySQL][PHP] Profil użytkownika
Deotho
post
Post #1





Grupa: Zarejestrowani
Postów: 79
Pomógł: 0
Dołączył: 2.05.2012
Skąd: Hogwart

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


Witam!
Mam mały problem z działaniem kodu odsyłacza do profilu.

profile.php
  1. <?php
  2. include('config/db.php');
  3. include('templates/header.php');
  4. ?>
  5.  
  6. <?php if (!isset($_SESSION['login'])) { echo '<center>Aby zobaczyć profil użytkownika zaloguj się.</center>'; } else {?>
  7.  
  8. <?php
  9. $id = $_GET['id'];
  10.  
  11. if(is_numeric($id)) {
  12.  
  13. $query = mysql_query("SELECT * FROM users WHERE id = '$id'");
  14. $user = mysql_fetch_array($query);
  15.  
  16. echo 'Profil użytkownika '.$user['login'];
  17.  
  18. }
  19.  
  20. } ?>
  21.  
  22. <?php include('templates/footer.php'); ?>


header.php
  1. <?php if (!isset($_SESSION['login'])) { echo ''; } else {?>
  2. <li><a href="profile.php?id=$id;">Profil</a></li>
  3. <?php } ?>


Zamiast $id; powinnien być ID użytkownika. 1, 2, lub 8.

questionmark.gif
Go to the top of the page
+Quote Post
Spawnm
post
Post #2





Grupa: Moderatorzy
Postów: 4 069
Pomógł: 497
Dołączył: 11.05.2007
Skąd: Warszawa




Daj $id w <??>
Go to the top of the page
+Quote Post
Deotho
post
Post #3





Grupa: Zarejestrowani
Postów: 79
Pomógł: 0
Dołączył: 2.05.2012
Skąd: Hogwart

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


Teraz ID przyjmuje wartość null = pusto.

Kod
http://localhost/profile.php?id=
Go to the top of the page
+Quote Post
johny_s
post
Post #4





Grupa: Zarejestrowani
Postów: 594
Pomógł: 122
Dołączył: 17.07.2005
Skąd: P-na

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


to moze jeszcze dodaj echo wink.gif
Go to the top of the page
+Quote Post
Deotho
post
Post #5





Grupa: Zarejestrowani
Postów: 79
Pomógł: 0
Dołączył: 2.05.2012
Skąd: Hogwart

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


  1. <?php if (!isset($_SESSION['login'])) { echo ''; } else {?>
  2. <li><a href="profile.php?id=<? echo '$id;'; ?>">Profil</a></li>
  3. <?php } ?>


Nic.
Go to the top of the page
+Quote Post
johny_s
post
Post #6





Grupa: Zarejestrowani
Postów: 594
Pomógł: 122
Dołączył: 17.07.2005
Skąd: P-na

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


chwial,

header.php includujesz na gorze, a id pobierasz pozniej, id sobie musisz pobrac wczesniej
Go to the top of the page
+Quote Post
patrysiek2
post
Post #7





Grupa: Zarejestrowani
Postów: 108
Pomógł: 5
Dołączył: 8.12.2011
Skąd: Łomża

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


  1. <?php if (!isset($_SESSION['login'])) { echo ''; } else {
  2. echo '<li><a href="profile.php?id='.$id.';">Profil</a></li>';
  3. }


--------------------
if($problem == 1)
{
header("Location: http://www.forum.php.pl");
}
else
{
thinking();
}
Go to the top of the page
+Quote Post

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: 22.08.2025 - 04:49