Kawałek kodu strony logowanie.php
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['form_name'] == 'loginform')
{
$success_page = './info_dodaj.php';
$error_page = './error_page.html';
$mysql_server = 'localhost';
$mysql_login = 'root';
$mysql_haslo = '';
$mysql_database = 'www';
$mysql_table = 'uzytkownicy';
$crypt_pass = md5($_POST['haslo']); $found = false;
$imie = '';
if (!$db)
{
}
$sql = "SELECT haslo, imie, status FROM ".$mysql_table." WHERE login = '".mysql_real_escape_string($_POST['login'])."'"; {
if ($crypt_pass == $data['haslo'] && $data['status'] != 0)
{
$found = true;
$imie = $data['imie'];
}
}
if($found == false)
{
header('Location: '.$error_page); }
else
{
{
}
$_SESSION['login'] = $_POST['login'];
$_SESSION['imie'] = $imie;
$rememberme = isset($_POST['rememberme']) ?
true : false; if ($rememberme)
{
}
header('Location: '.$success_page); }
}
$login = isset($_COOKIE['login']) ?
$_COOKIE['login'] : ''; $haslo = isset($_COOKIE['haslo']) ?
$_COOKIE['haslo'] : ''; ?>
<meta http-equiv="Content-Language" content="pl"> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-2"> <meta name="author" content="Bogumił Kraszewski"> <link rel="shortcut icon" href="Favorites.ico"> html, body
function Validateloginform(theForm)
{
var regexp;
regexp = /^[A-Za-zAÁÂAÄAAÇEÉEËIÍÎIDNOÓÔOÖOUÚUÜÝ?ßaáâaäaaçeéeëiíîi?noóôoöouúuüý?y0-9-]*$/;
if (!regexp.test(theForm.Editbox1.value))
{
alert("Wpisz Login!");
theForm.Editbox1.focus();
return false;
}
if (theForm.Editbox1.value == "")
{
alert("Wpisz Login!");
theForm.Editbox1.focus();
return false;
}
if (theForm.Editbox2.value == "")
{
alert("Wpisz Hasło!");
theForm.Editbox2.focus();
return false;
}
return true;
}
//-->
<div id="wb_Shape10" style="position:absolute;left:249px;top:0px;width:402px;height:52px;z-index:10;"> <img src="images/logowanie_0011.png" id="Shape10" alt="" style="border-width:0;width:402px;height:52px;"></div> <div id="wb_loginform" style="position:absolute;left:231px;top:90px;width:436px;height:199px;z-index:11;"> <form name="loginform" method="post" action="<?php echo basename(__FILE__); ?>" id="loginform" onsubmit="return Validateloginform(this)">
<input type="hidden" name="form_name" value="loginform"> <div id="wb_lock1" style="position:absolute;left:0px;top:0px;width:180px;height:180px;z-index:0;"> <img src="images/login.png" id="lock1" alt="" border="0" style="width:180px;height:180px;"></div> <div id="wb_Text2" style="position:absolute;left:176px;top:28px;width:78px;height:18px;text-align:right;z-index:1;"> <div><span style="color:#000000;font-family:Tahoma;font-size:15px;"> Login
</span></div> <div id="wb_Text3" style="position:absolute;left:176px;top:69px;width:78px;height:18px;text-align:right;z-index:2;"> <div><span style="color:#000000;font-family:Tahoma;font-size:15px;"> Hasło
</span></div> <hr id="Line1" class="ui-widget-header" style="margin:0;padding:0;position:absolute;left:181px;top:150px;width:237px;heigh
t:1px;z-index:3;"> <input type="text" id="Editbox1" onfocus="SetStyle('Editbox1', 'stylramkafocus1');return false;" onblur="SetStyle('Editbox1', 'stylramka1');return false;" class="stylramka1" style="position:absolute;left:264px;top:25px;width:148px;height:23px;line-height:23px;z-index:4;" name="login" value="<?php echo $login; ?>">
<input type="password" id="Editbox2" onfocus="SetStyle('Editbox2', 'stylramkafocus1');return false;" onblur="SetStyle('Editbox2', 'stylramka1');return false;" class="stylramka1" style="position:absolute;left:264px;top:65px;width:148px;height:23px;line-height:23px;z-index:5;" name="haslo" value="<?php echo $haslo; ?>">
<button id="AdvancedButton1" onmouseover="ShowObjectWithEffect('AdvancedButton2', 0, 'fade', 300);return false;" onmouseout="ShowObjectWithEffect('AdvancedButton2', 1, 'fade', 300);return false;" type="submit" name="login" value="Loguj" class="button1" style="position:absolute;left:184px;top:164px;width:110px;height:25px;z-index:6;"><div style="text-align:center"><span style="color:#FFFFFF;font-family:Tahoma;font-size:15px">Loguj
</span></div></button> <button id="AdvancedButton2" onmouseover="ShowObjectWithEffect('AdvancedButton1', 0, 'fade', 300);return false;" onmouseout="ShowObjectWithEffect('AdvancedButton1', 1, 'fade', 300);return false;" type="button" onclick="window.location='rejestracja.php'" name="" value="rejestruj" class="button1" style="position:absolute;left:312px;top:164px;width:110px;height:25px;z-index:7;"><div style="text-align:center"><span style="color:#FFFFFF;font-family:Tahoma;font-size:15px">Rejestracja
</span></div></button> <div id="wb_Text8" style="position:absolute;left:282px;top:105px;width:100px;height:16px;z-index:8;text-align:left;"> <span style="color:#000000;font-family:Tahoma;font-size:13px;">Pamiętaj mnie
</span></div> <input type="checkbox" id="rememberme" name="rememberme" value="on" style="position:absolute;left:265px;top:104px;z-index:9;"> <div id="wb_Text5" style="position:absolute;left:231px;top:308px;width:438px;height:16px;text-align:center;z-index:12;">
Moja tabela `użytkownicy`:
CREATE TABLE IF NOT EXISTS `uzytkownicy` (
`user_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`login` varchar(25) NOT NULL,
`imie` varchar(100) NOT NULL,
`nazwisko` varchar(100) NOT NULL,
`haslo` varchar(50) NOT NULL,
`data_rejestracji` datetime NOT NULL,
`status` tinyint(1) NOT NULL,
PRIMARY KEY (`user_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin2 AUTO_INCREMENT=1 ;
Problem: nie mogę zalogować się użytkownikiem, który jest w bazie. Nie wyświetla mi żadnego błędu mysql, jedynie przekierowuje mnie na error_page.html w przypadku niepoprawnego zalgowania.
Stworzyłem użytkownika "a" z takim samym nazwiskiem, hasłem itd... status ręcznie zmieniłem na "1" w bazie (1 = aktywny).
Pytanie: co w tym kodzie jest źle wpisane? Pewnie jakaś błachostka, ale spać mi to nie daje

Domyślam się, że to może być błąd w formularzu, tylko gdzie?
Proszę o pomoc.
Ten post edytował gogomania 27.02.2013, 19:15:34