Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP] logowanie, blad w kodzie
integral
post 23.03.2011, 13:55:58
Post #1





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 9.03.2011

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


witam, proboje zrobic krok po kroku logowanie w php tak jak w pewnym tutorialu, wszystko dziala niby ok ale nie wiem dlaczego wywala takze cos takiego:
Cytat
Notice: Use of undefined constant password - assumed 'password' in C:\xampp\htdocs\strona\login.php on line 6

index:
  1. <form action="login.php" method="POST">
  2. Username: <input type="text" name="username"><br>
  3. Password: <input type="password" name="password"><br>
  4. <input type="submit" value="Log in">
  5. </form>
  6. </html>

login:
  1. <?php
  2.  
  3. $username = $_POST['username'];
  4. $password = $_POST['password'];
  5.  
  6. if ($username && password) {
  7. $connect = mysql_connect('localhost', 'root', '') or die('Couldnt connecy!');
  8. mysql_select_db('phplogin') or die('couldnt find db.');
  9.  
  10. $query = mysql_query("SELECT * FROM users WHERE username='$username'");
  11. $numrows = mysql_num_rows($query);
  12.  
  13. if ($numrows != 0) {
  14. while ($row = mysql_fetch_assoc($query)){
  15. $dbusername=$row['username'];
  16. $dbpassword=$row['password'];
  17. }
  18. //check to see if they match!
  19. if($username==$dbusername && $password==$dbpassword){
  20. echo"You're in!";
  21. }
  22. else{
  23. echo "Incorrect password!";
  24. }
  25. }
  26. else
  27. die('That user doesnt exist!');
  28. }
  29. else
  30. die('Please enter and username and a password!');
  31. ?>

Go to the top of the page
+Quote Post
redelek
post 23.03.2011, 13:59:28
Post #2





Grupa: Zarejestrowani
Postów: 658
Pomógł: 37
Dołączył: 4.06.2005
Skąd: Wawa

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


zgubiłeś dolarek $

  1. if ($username && $password)


--------------------
Pozdrawiam
Piotrek R
Go to the top of the page
+Quote Post
mat-bi
post 23.03.2011, 14:44:04
Post #3





Grupa: Zarejestrowani
Postów: 690
Pomógł: 92
Dołączył: 6.02.2011

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


Ludzie, angielski się kłania

Notice: Use of undefined constant password - assumed 'password' in C:\xampp\htdocs\strona\login.php on line 6 - Notatka: Użycie niezadeklarowanej stałej "password" - przypusczalnie 'password' w itd.

tak BTW - poczytaj o SQL Injection
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: 13.08.2025 - 22:22