Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Gdzie jest błąd w skrypcie, Logowanie - sesje
gallardo83
post 5.11.2007, 15:11:15
Post #1





Grupa: Zarejestrowani
Postów: 24
Pomógł: 0
Dołączył: 5.11.2007

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


Witam wszystkich
Właśnie zabrałem sie za skrypt logowania na moją stronę z wykorzystaniem sesji, niestety kiedy się loguję - to pomimo wpisania dobrego hasła i loginu wyskakuje błąd, że haslo albo login są niepoprawne. Bardzo proszę o pomoc !
Oto pliki :
index.php
<?php session_start();?>

<?php


if(!empty($_GET['page']))
$file = 'include/'.$_GET['page'].'.php';
else $file = 'include/witam.php';
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Programowanie aplikacji internetowych</title>
<link href="style/tło.css" rel="stylesheet" type="text/css" />
</head>

<body>
<table width="100%" border="1">
<tfoot><tr><td colspan="2"></td></tr></tfoot>
<tr>
<td width="15%" height="190"><img src="images/dominik.jpg" width="243" height="211" /></td>
<td width="85%">

<form id="form1" name="form1" method="post" action="index.php?page=loguj_script">
<table width="11%" border="1" align="right" cellpadding="0" cellspacing="0">
<tr>
<td><label>Logowanie:
<input name="login_check" type="text" size="25" class="textarea" />
</label></td>
</tr>
<tr>
<td><label>Haslo:
<input name="pass_check" type="password" size="25" class="textarea" />
</label></td>
</tr>
<tr>
<td><div align="center">
<input type="submit" name="submit" value="Login" />
</div></td>
</tr>
<tr>
<td><div align="center"><a href="index.php?page=rejestracja_form1">Rejestracja</a></div><div align="center">Zapomniałeś hasła -<a href="login/zapomniane_form.php"> KLIKNIJ </a></div></td>
</tr>
</table>
</form>


<div align="center">
<p><strong>POLITECHNIKA Ł&Oacute;DZKA</strong></p>
<p>Instytut informatyki </p>


</div></td>

</tr>
<tr>
<td align="top" height="663"><?php include('include/menu.php');?></td>
<td>
<?php
if(file_exists($file))
include($file);
else include('include/error.php');
?>
</td>
</tr>
</table>
</body>
</html>

loguj_script.php

<?php
session_start();
?>

<?php
$login_check = $_POST['login_check'];
$pass_check = $_POST['pass_check'];

if (!file_exists("users/$login_check.dat")):
echo("Błędne dane");
elseif (file_exists("users/$login_check.dat")):
include("users/$login_check.dat");
if(($_SESSION['login'] == $login_check) && ($_SESSION['password'] == $pass_check)): // cos tutaj chyba jest nie tak ?
echo ("witamy");
echo $_SESSION['login'];
echo("Zalogowałeś si&#281!!");
else:
echo("niepoprawny login lub/i hasło");
endif;
endif;

?>

Bardzo proszę o rodę
Go to the top of the page
+Quote Post
nevt
post 5.11.2007, 15:18:38
Post #2





Grupa: Przyjaciele php.pl
Postów: 1 595
Pomógł: 282
Dołączył: 24.09.2007
Skąd: Reda, Pomorskie.

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


Witaj.
W kodzie który pokazałeś nigdzie nie inicjujesz $_SESSION['login'] oraz $_SESSION['password']. Można domniemać, że są cały czas puste... Wtedy warunek się nie sprawdzi...


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

-
Oh no, my young coder. You will find that it is you who are mistaken, about a great many things... -
Go to the top of the page
+Quote Post
Cysiaczek
post 5.11.2007, 16:11:18
Post #3





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




Popraw proszę tytuł topiku na zgodny z zasadami forum Przedszkole o dodaj bbcode


--------------------
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
marcio
post 5.11.2007, 18:58:03
Post #4





Grupa: Zarejestrowani
Postów: 2 291
Pomógł: 156
Dołączył: 23.09.2007
Skąd: ITALY-MILAN

Ostrzeżenie: (10%)
X----


sorki za offtop bo nie chce czytac calego kodu ale czy to nie jest poinson null byte jesli tak to popraw
OMG usunelo mi sie przez przypadek sorki

a wiec napisze jeszcze raz ten kod wedlug mnie nie jest poprawny:
  1. <?php
  2. if(!empty($_GET['page']))
  3. $file = 'include/'.$_GET['page'].'.php';
  4. else $file = 'include/witam.php';
  5. ?>

mozna to tak wykorzystac
  1. <?php
  2. "http://www.strona.pl?page=plik.html" // i tu za html dodaje sie '' bez tych '' bo nie dodaje tego nie wiem czemu
  3. ?>

i kod sie zmienia na taki po dodaniu
  1. <?php
  2. if(!empty($_GET['page']))
  3. $file = 'include/'.$_GET['page'].'.html' '.php'; // czyli po zakonczeniu stringu/ostatni bajt rozszerzenia php nie widac biggrin.gif aha tu tak samo po html dodaje sie 
  4. // '' bez tych ''
  5. else $file = 'include/witam.php';
  6. ?>

uzyj przynajmniej basename() z przyrostkiem php i wtedy w url nie bedzie rozszerzenia pliku smile.gif

Ten post edytował marcio 5.11.2007, 19:00:13


--------------------
Zainteresowania: XML | PHP | MY(SQL)| C# for .NET | PYTHON
http://code.google.com/p/form-builider/
Moj blog
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.06.2025 - 20:09