Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [php]Problem przy logowaniu do mojej strony
Forum PHP.pl > Forum > Przedszkole
Quik
Witam. Podczas logowania do własnej strony (gry) mam problem. Poniżej przedstawiam kod php pliku index.php
  1. <?php include("head.php");
  2. echo("<title>$gm</title>");
  3. ?>
  4. <center><table width="200" border="0">
  5. <tr>
  6. <td><center><b>Witaj w królestwie AshVall!</b></center></td>
  7. </tr>
  8. </table></center>
  9. <br>
  10. <br>
  11. <center><table width="600" border="0">
  12. <tr>
  13. <td><center>Jakas tam Historyjka</center></td>
  14. </tr>
  15. </table></center>
  16. <br>
  17. <br>
  18. <center><table width="40" border="0">
  19. <tr>
  20. <td><center>Logowanie</center></td>
  21. </tr>
  22. </table></center>
  23. <br>
  24. <br>
  25. <center><table width="200" border="0">
  26. <tr>
  27. <td><form method=post action=player.php>
  28. <center><b>Login:</b> <input name="login" type="text"></center>
  29. <center><b>Haslo:</b> <input name="pass" type="password"></center>
  30. <center><input name="" type="submit" value="Loguj"></center>
  31. </form>
  32. </td>
  33. </tr>
  34. </table></center>
  35. <?php include("foot.php")?>


oto plik header.php
  1. <?php
  2. if (!$login || !$pass) {
  3. include("head.php");
  4. print "Wypełnij wsyzstkie pola!";
  5. include("foot.php");
  6. }
  7. include("head.php");
  8. $logres = mysql_num_rows(mysql_query("select * from players where user='$login' and pass='$pass'"));
  9. if ($logres <= 0) {
  10. print "Logowanie nieudane. Sprawdź pisownie loginu oraz hasła.";
  11. include("foot.php");
  12. } else {
  13. }
  14. ?>
  15. <?php include("config.php"); session_start(); ?>
  16. <link rel=stylesheet href=style.css>
  17. <?php
  18. if (!session_is_registered("user") || !session_is_registered("pass")) {
  19. print "Sesia zakończyła się. Zostałeś wylogowany bądź nie możesz się zalogować.. <a href=index.php>Strona Glowna</a>";
  20. }
  21. $stat = mysql_fetch_array(mysql_query("select * from players where user='$login' and pass='$pass'"));
  22. if (empty ($stat[id])) {
  23. print "Nieprawidłowe logowanie. <a href=index.php>Strona Glowna</a>";
  24. }
  25. $ctime = time();
  26. mysql_query("update players set lpv=$ctime where id=$stat[id]");
  27. $ip = "$HTTP_SERVER_VARS[REMOTE_ADDR]";
  28. mysql_query("update players set ip='$ip' where id=$stat[id]");
  29. mysql_query("update players set page='$title' where id=$stat[id]");
  30. ?>
  31. <?php echo("<title>$gm - $title</title>"); ?>
  32. <center><img src="images/ashvall.gif" alt="AshVall MMORPG" /></center>
  33.  
  34. <center><table width="200" border="0">
  35. <tr>
  36. <th scope="row">
  37. <?php
  38. print "<center><b><u>$stat[user]</b></u> ($stat[id])</center><br>";
  39. print "Poziom: $stat[level]<br>";
  40. print "HP: $stat[hp] / $stat[max_hp]<br>";
  41. print "Mana: $stat[mana] / $stat[max_mana]<br>";
  42. print "Energia: $stat[energy] / $stat[max_energy]<br>";
  43.  
  44. ?>
  45. <a href=?logout><img src="images/exit.gif" alt="wyloguj" /></a>
  46. </th>
  47. </tr>
  48. </table></center><br /><br />
  49.  
  50. <center><table width="400" border="0">
  51. <tr>
  52. <th scope="row">
  53. <?php
  54. echo("$title");
  55. ?></th>
  56. </tr>
  57. </table></center>
  58. <br />


A problem polega na tym, że przy logowaniu wpisuje poprawnie wszystkie dane i po wciśnięciu przycisku loguj wyswietla mi się "Wypełnij wszystkie pola". I jeszcze jedno. Przy testowaniu gry na moim kompie wszystko było ok, a gdy juz przeniosłem gre na server UGU.PL to właśnie mam ten problem. Proszę o pomoc.


Dziękuje.
Cysiaczek
Dyrektywa register_globals w php.ini.
Napisałeś aplikację w archaiczny sposób, więc cierp : >
Naucz się korzystać z tablic $_POST , $_GET, $_SESSION

Pozdrawiam.
Quik
aha. Dopiero zaczynam biggrin.gif. ale czy da się naprawic ten błąd? (wzorowałem się na Gamers-Fusion smile.gif)
Cysiaczek
To nie jest błąd, tylko złe programowanie. Napisałem Ci - dyrektywa register_globals. Ustaw na Off na swoim lokalnym serwerze i też przestanie Ci działać ta aplikacja. Jedyne, co mżesz zrobić teraz, to przepisać kod tak, aby nie korzystał ze zmiennych globalnych i takich funkcji jak session_register($foo);
http://pl2.php.net/manual/pl/ref.session.php
  1. <?php
  2. if(!$_POST['login'] && !$_POST['pass'])
  3. ?>
Quik
Aha. Dzięki Ci. Tak zrobię smile.gifsmile.gif Zaczne studiować Zmienne haha.gif.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.