Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [php/mysql] Problem z logowaniem
lan
post 22.12.2006, 10:30:00
Post #1





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 21.11.2006

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


Witam mam taki problem z logowaniem.. co kolwiek wpisze to zawsze otrzymuje rezultat ze nei zalogowano:

logowanie:
  1. <?php
  2. <form action="loguj.php" method="get">
  3. Login:&nbsp;&nbsp;&nbsp;
  4. <input type="text" NAME="nick1" SIZE=10/><br />
  5. Hasło:&nbsp;&nbsp;&nbsp;
  6. <input type=password NAME="pass1" SIZE=10/><br />
  7. <INPUT TYPE="submit" VALUE="Loguj" style="background:url(lay_graf/belka3.jpg); font-size: 10pt; font-family: Times New Roman; Font-style: italic; font-weight: bold; padding-top: 3px; padding-left: 3px;">
  8. </form>
  9. </td>
  10. </tr>
  11. <tr>
  12. ?>


laczenie z baza etc:
  1. <?php
  2. $conn=mysql_connect("localhost","root","haslo") or die ("Nie mozna polaczyc z baza danych!");
  3. mysql_select_db("liga", $conn);
  4. if ($_GET['nick1'] && $_GET['pass1']) {
  5.  
  6. $nick1= addslashes($_GET['nick1']);
  7. $pass1= md5(md5($_GET['pass1']));
  8.  
  9. mysql_query("SELECT * FROM `rejestracja` WHERE `$nick1` = 'nick' AND `$pass1` = 'pass' LIMIT 1");
  10.  
  11. if(mysql_num_rows() == 1) {
  12. print'zalogowano $nick1';
  13. } else
  14. {
  15. print'NIE ZALOGOWANO !';
  16. }
  17. }
  18. ?>


Nie wiem o co chodzi .. probowalem roznych kombnacji
Go to the top of the page
+Quote Post
Cysiaczek
post 22.12.2006, 10:35:28
Post #2





Grupa: Moderatorzy
Postów: 4 465
Pomógł: 137
Dołączył: 26.03.2004
Skąd: Gorzów Wlkp.




Brak argumentu dla mysql_num_rows()

Pozdrawiam.


--------------------
To think for yourself you must question authority and
learn how to put yourself in a state of vulnerable, open-mindedness;
chaotic, confused, vulnerability, to inform yourself.
Think for yourself. Question authority.
Go to the top of the page
+Quote Post
nospor
post 22.12.2006, 10:36:28
Post #3





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




zobacz w manualu jaki wymagany parametr przyjmuje mysql_num_rows():
http://pl.php.net/manual/pl/function.mysql-num-rows.php

Dodatkowo masz zle zapytanie. powinno byc:
  1. <?php
  2. $res = mysql_query("SELECT * FROM `rejestracja` WHERE nick = '$nick1' AND pass = '$pass1' LIMIT 1");
  3. ?>



ps: przenosze


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
lan
post 22.12.2006, 11:25:59
Post #4





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 21.11.2006

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


Hmm teraz mam cos takiego:
  1. <?php
  2. $link = mysql_connect ('localhost','root','haslo);
  3. mysql_select_db('liga', $link);
  4. if ($_GET['nick1'] && $_GET['pass1']) {
  5.  
  6. $nick1= addslashes($_GET['nick1']);
  7. $pass1= md5(md5($_GET['pass1']));
  8.  
  9. $result = mysql_query("SELECT * FROM `rejestracja` WHERE nick = '$nick1' AND pass = '$pass1', LIMIT 1", $link);
  10. $num_rows = mysql_num_rows($result); 
  11. if(mysql_num_rows() == 1) {
  12. print'zalogowano $nick1';
  13. } else
  14. {
  15. print'NIE ZALOGOWANO !';
  16. }
  17. }
  18. ?>


I otrzymuje:

  1. <?php
  2. Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in D:Program FilesApache GroupApache2htdocsloguj.php on line 10
  3.  
  4. Warning: Wrong parameter count for mysql_num_rows() in D:Program FilesApache GroupApache2htdocsloguj.php on line 11
  5. NIE ZALOGOWANO !
  6. ?>
Go to the top of the page
+Quote Post
fx69
post 22.12.2006, 11:31:27
Post #5





Grupa: Zarejestrowani
Postów: 40
Pomógł: 0
Dołączył: 8.10.2006
Skąd: świat astralny

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


  1. <?php
  2. $link = mysql_connect ('localhost','root','haslo);
  3. mysql_select_db('liga', $link);
  4. if ($_GET['nick1'] && $_GET['pass1']) {
  5.  
  6. $nick1= addslashes($_GET['nick1']);
  7. $pass1= md5(md5($_GET['pass1']));
  8.  
  9. $result = mysql_query("SELECT * FROM `rejestracja` WHERE nick = '$nick1' AND pass = '$pass1', LIMIT 1", $link);
  10. $num_rows = mysql_num_rows($result); 
  11. if(mysql_num_rows() == 1) {
  12. print'zalogowano $nick1';
  13. } else
  14. {
  15. print'NIE ZALOGOWANO !';
  16. }
  17. }
  18. ?>


ciekawe czemu tak pokolorowało, no nie ? :roll2:

spróbuj tak:
  1. <?php
  2. $num_rows = mysql_num_rows($result);
  3. if($num_rows == 1) {
  4. ...
  5. ?>


Ten post edytował fx69 22.12.2006, 11:37:53
Go to the top of the page
+Quote Post
lan
post 22.12.2006, 11:35:10
Post #6





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 21.11.2006

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


  1. <?php
  2. Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in D:Program FilesApache GroupApache2htdocsloguj.php on line 10
  3. NIE ZALOGOWANO !
  4. ?>
Go to the top of the page
+Quote Post
nospor
post 22.12.2006, 11:55:32
Post #7





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




w zapytaniu przed limit nie powinno byc przecinka


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

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 Wersja Lo-Fi Aktualny czas: 16.06.2025 - 21:16