Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Biała strona po wejściu na index.php
Gruchol
post 2.01.2015, 11:56:43
Post #1





Grupa: Zarejestrowani
Postów: 242
Pomógł: 0
Dołączył: 28.11.2014

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


Witam,
Napisałem taki skrypt logowania :

  1. <!DOCTYPE HTML>
  2. <?php
  3. ?>
  4. <html lang="pl">
  5. <head>
  6. <title>Sklepik</title>
  7. <style type="text/css">
  8. body {
  9. background:url(../res/background.jpg);
  10. background-repeat:no-repeat;
  11. background-position:top center;
  12. background-color:#000000;
  13. font-family: Tahoma, Arial, Helvetica, sans-serif;
  14. color: #FFFFFF;
  15. margin: 188px auto auto 0;
  16. }
  17. a:link { text-decoration:none; color:#ffd9aa; }
  18. a:visited { text-decoration:none; color:#ffd9aa; }
  19. a:hover { text-decoration:underline; color:#ffd9aa; }
  20. a:active { text-decoration:none; color:#ffd9aa; }
  21. a:focus { text-decoration:none; color:#ffd9aa; }
  22. h1{
  23. font-size: 1.2em;
  24. font-weight: bold;
  25. padding:0;
  26. margin:0;
  27. margin-bottom: 0.5em;
  28. }
  29. .imprint2 {
  30. margin-top: 130px;
  31. color: #000000;
  32. }
  33. .imprint2 a {
  34. color: #000000;
  35. text-decoration: underline;
  36. }
  37. input[type=text], textarea, input[type=password] {
  38. border: 1px solid #929292;
  39. color: #929292;
  40. padding: 10px;
  41. vertical-align: text-top;
  42. width: 300px;
  43. -webkit-box-shadow: #e3e3e3 0.1em 0.1em 0.2em;
  44. box-shadow: #e3e3e3 0.1em 0.1em 0.2em;
  45. -moz-box-shadow: #e3e3e3 0.1em 0.1em 0.2em;
  46. -webkit-border-radius: 5px;
  47. -moz-border-radius: 5px;
  48. -border-radius: 5px;
  49. -khtml-border-radius: 5px;
  50. background: -webkit-gradient(linear, left top, left 25, from(#FFFFFF), color-stop(4%, #EEEEEE), to(#FFFFFF));
  51. background: -moz-linear-gradient(top, #FFFFFF, #EEEEEE 1px, #FFFFFF 25px);
  52. }
  53. input[type=submit] {
  54. border: 1px solid #929292;
  55. color: #000;
  56. font-weight: bold;
  57. padding: 10px;
  58. vertical-align: text-top;
  59. width: auto;
  60. -webkit-box-shadow: #e3e3e3 0.1em 0.1em 0.2em;
  61. box-shadow: #e3e3e3 0.1em 0.1em 0.2em;
  62. -moz-box-shadow: #e3e3e3 0.1em 0.1em 0.2em;
  63. -webkit-border-radius: 5px;
  64. -moz-border-radius: 5px;
  65. -border-radius: 5px;
  66. -khtml-border-radius: 5px;
  67. background: -webkit-gradient(linear, left top, left 25, from(#FFFFFF), color-stop(4%, #EEEEEE), to(#FFFFFF));
  68. background: -moz-linear-gradient(top, #FFFFFF, #EEEEEE 1px, #FFFFFF 25px);
  69. }
  70.  
  71. </style>
  72. </head>
  73. <body>
  74. <center>
  75. <br>
  76. <br>
  77. <br>
  78. <br>
  79. <form method="post" action="">
  80. Nick z gry :
  81. <br>
  82. <br>
  83. <input type="text" name="login"/>
  84. <br>
  85. <br>
  86. Hasło :
  87. <br>
  88. <br>
  89. <input type="password" name="haslo"/>
  90. <br>
  91. <br>
  92. <input type="submit" value="Zaloguj się!"/>
  93. </form>
  94. </center>
  95. <?php
  96. $db = mysqli_connect(dane)
  97. @$login = $_POST["login"];
  98. @$haslo = $_POST["haslo"];
  99. $haslozbazy = mysqli_query($db, "SELECT password FROM user_data WHERE user_name='$login'");
  100. $haslozbazy1 = $haslozbazy->fetch_assoc()['password'];
  101. $haslo1 = md5($haslo);
  102. $loginsprawdz = mysqli_query($db, "SELECT user_name FROM user_data WHERE password='$haslo1'");
  103. $loginsprawdz1 = $loginsprawdz->fetch_assoc()['user_name'];
  104. $id = mysqli_query($db, "SELECT user_id FROM user_data WHERE user_name='$login'");
  105. $id1 = $id->fetch_assoc()['user_id'];
  106. echo "$id1";
  107. if($haslozbazy1 == $haslo1 and $login == $loginsprawdz1) {
  108. $_SESSION["logged"] = true;
  109. $_SESSION["login"]=$_POST["login"];
  110. header('location: shop.php');
  111. }
  112. elseif(!empty($login or $haslo)) {
  113. echo "<center><h2>Login lub hasło jest błędne.<h2/></center>";
  114. }
  115.  
  116. ?>
  117.  
  118. </body>
  119. </html>


Problem polega na tym, że po wejściu na index.php i po zmianie nazwy też zamiast panelu pojawia się biała strona bez żadnych błędów.
Na localhoscie ( xampp ) wszystko działa jednak na VPSie mam Nginx strona jest biała.

Ten post edytował Gruchol 2.01.2015, 11:57:19
Go to the top of the page
+Quote Post
Turson
post 2.01.2015, 11:59:52
Post #2





Grupa: Zarejestrowani
Postów: 4 291
Pomógł: 829
Dołączył: 14.02.2009
Skąd: łódź

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


Raportowanie błedów!
Obstawiam na "Headers already sent"...
Go to the top of the page
+Quote Post
Gruchol
post 2.01.2015, 12:26:30
Post #3





Grupa: Zarejestrowani
Postów: 242
Pomógł: 0
Dołączył: 28.11.2014

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


Włączyłem raportowanie w php.ini i dopisałem :
<?
error_reporting(E_ALL);
?>
w index.php, wgrałem inny w 100% działający i nadal jest biała strona..
Chyba jest coś nie tak z nginxem.

Zrobiłem nowe konto użytkownika i wstawiłem tam index teraz wyświetliło mi coś takiego :

fetch_assoc()['password']; $haslo1 = md5($haslo); $loginsprawdz = mysqli_query($db, "SELECT user_name FROM user_data WHERE password='$haslo1'"); $loginsprawdz1 = $loginsprawdz->fetch_assoc()['user_name']; $id = mysqli_query($db, "SELECT user_id FROM user_data WHERE user_name='$login'"); $id1 = $id->fetch_assoc()['user_id']; echo "$id1"; if($haslozbazy1 == $haslo1 and $login == $loginsprawdz1) { $_SESSION["logged"] = true; $_SESSION["login"]=$_POST["login"]; header('location: shop.php'); } elseif(!empty($login or $haslo)) { echo "
Login lub hasło jest błędne.

"; } ?>
Do tego w źródle strony widać cały kod php.
Go to the top of the page
+Quote Post
Turson
post 2.01.2015, 12:29:17
Post #4





Grupa: Zarejestrowani
Postów: 4 291
Pomógł: 829
Dołączył: 14.02.2009
Skąd: łódź

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


Plik ma rozszerzenie .php? Masz w ogóle tam PHP zainstalowane?
Go to the top of the page
+Quote Post
Gruchol
post 2.01.2015, 12:31:53
Post #5





Grupa: Zarejestrowani
Postów: 242
Pomógł: 0
Dołączył: 28.11.2014

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


Tak mam zainstalowane php-fpm.
Teraz zauważyłem że to był jednak plik index.html i nadpisałem nie ten co miałem.

Nadal jest biała strona.

Jak bym nie miał zainstalowanego php to przeglądarka pobierała by plik .php zamiast go odtwarzać.

Ten post edytował Gruchol 2.01.2015, 12:33:09
Go to the top of the page
+Quote Post
markuz
post 2.01.2015, 12:32:02
Post #6





Grupa: Zarejestrowani
Postów: 1 240
Pomógł: 278
Dołączył: 11.03.2008

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


Masz w ini short_open_tag = on? Jeżeli nie to zaczynaj od <?php


--------------------
Go to the top of the page
+Quote Post
Gruchol
post 2.01.2015, 12:40:03
Post #7





Grupa: Zarejestrowani
Postów: 242
Pomógł: 0
Dołączył: 28.11.2014

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


Mam :
; This directive determines whether or not PHP will recognize code between
; <? and ?> tags as PHP source which should be processed as such. It is
; generally recommended that <?php and ?> should be used and that this feature
; should be disabled, as enabling it may result in issues when generating XML
; documents, however this remains supported for backward compatibility reasons.
; Note that this directive does not control the <?= shorthand tag, which can be
; used regardless of this directive.
; Default Value: On
; Development Value: Off
; Production Value: Off
; http://php.net/short-open-tag
short_open_tag = On

Wklejałem linijka po linijce kod sprawdzając kiedy zrobi się biały obraz i robi się gdy dodam to :

  1. elseif(!empty($login or $haslo)) {
  2. echo "<center><h2>Login lub hasło jest błędne.<h2/></center>";
  3. }

Co w tym jest nie tak?

Ten post edytował Gruchol 2.01.2015, 12:49:38
Go to the top of the page
+Quote Post
irytek
post 2.01.2015, 12:59:18
Post #8





Grupa: Zarejestrowani
Postów: 16
Pomógł: 5
Dołączył: 31.12.2014

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


Wpisz tak:
  1. if(!empty($login) or !empty($haslo)){


nie zauważym w manualu "empty" aby można byłe podawać multiple variables.

Dodatkowo faktycznie masz wyłączone raportowanie błędów.

Ten post edytował irytek 2.01.2015, 13:00:35
Go to the top of the page
+Quote Post
Gruchol
post 2.01.2015, 13:11:37
Post #9





Grupa: Zarejestrowani
Postów: 242
Pomógł: 0
Dołączył: 28.11.2014

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


Działa wielkie dzięki ! smile.gif
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: 14.07.2025 - 10:54