Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] logowanie
peter13135
post
Post #1





Grupa: Zarejestrowani
Postów: 1 447
Pomógł: 191
Dołączył: 26.03.2008

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


mam taki skrypt
  1. <form action="" method=post>
  2. login <input type="text" name="username" size="20" maxlenght="16"><br>
  3. hasło <input type="password" name="user_password" maxlenght="16"><br>
  4. <input type=submit value="zaloguj">
  5. </form>
  6.  
  7. <?
  8. $username=$_POST['username'];
  9. $user_password=$_POST['user_password'];
  10. if($username && $user_password)
  11. {
  12.  
  13.  
  14.  
  15.  
  16. @$db = mysql_pconnect("localhost", "user", "haslo");
  17. if (!$db)
  18. {  
  19. print "wystąpił błąd w połączeniu";  
  20. exit;
  21. }
  22.  
  23. mysql_select_db("nazwa bazy"); 
  24.  
  25. $query = "select * from clchat_users WHERE ".username." = $username AND ".user_password." = $user_password"; 
  26. $result = mysql_query($query);
  27. $row = mysql_fetch_array($result);
  28.  
  29.  
  30. print stripslashes($row["user_id"]);
  31. print "<br>";
  32. print stripslashes($row["username"]);
  33. print "<br>";
  34. print stripslashes($row["user_password"]);
  35. print "<br>";
  36. print stripslashes($row["user_active"]);
  37.  
  38. }
  39.  
  40. ?>


jestem bardzo początkujący w php,
to ma być skrypt logowania do prostego chatu

user_id > id usera
username > nazwa usera
user_password > hasło user
user_active > (jest albo 0 albo 1, jeżeli jest 1 to znaczy że user jest aktywowany przez admina)

jak narazie to prubuje wyświetlić informacje z bazy danych, ale mi sie to nieudaje ponieważ wyskakuje błąd
Kod
[b]Warning[/b]:  mysql_fetch_array(): supplied argument is not a valid MySQL result resource in [b]/home/ph/public_html/user1354/login.php[/b] on line [b]27
[/b]
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 - 14:39