Witam mam tutaj proste logowanie. Działa na mojej stronie lecz gdy wykupiłem nowy serwer i tworze stronę dla kogoś to skrypt nie loguje. Nie wiem może to wina bazy. Klikam na zaloguj i tak jak by w ogóle tylko tam header widziało i przenosi mnie od razu do index.php. Nie wyświetla się żaden komunikat a powinien w razie złego wpisania val 1 2 lub 3. Kod:
logowanie sam skrypt:
<?php
if(!isSet($_SESSION['kiczarowo'])){ echo "<form name='logowanie' method='post' action='x.php' onSubmit='var ok=sprawdzLogowanie(); return ok;'>"; if(isSet($_SESSION['komunikat'])){ echo $_SESSION['komunikat']; }
echo "<table align='center' width='40%'> <tr>
<td><input class='form1' size='18' name='login' type='text' maxlength='16' value='login' onClick='form1(this.value);' /></td>
<td><input class='form1' size='18' name='pass' type='password' maxlength='16' value='pass' onClick='form2(this.value);' /></td>
</tr>
<tr>
<td><input class='form2' name='haslo' type='submit' value='zaloguj' /></td>
<td><a style='display:none;' href='nowehaslo.php'>odzyskiwanie hasła</a></td>
</tr>
</table>
</form>";
}
else{
$user = $_SESSION['kiczarowo'];
<td>Lv: ".$user['id']."</td>
";
}
?>
A to skrypt sprawdzający logowanie :
<?php
function checkPass($login, $pass){
$query = "SELECT COUNT(*) FROM user WHERE user='$login' ";
$query .= "AND haslo='$pass'";
return 1;
}
return 1;
}
else{
if($row[0] <> 1){
return 2;
}
else{
return 0;
}
}
}
if(isSet($_SESSION['kiczarowo'])){ header("Location: index.php"); }
else if(!isSet($_POST["pass"]) || !isSet($_POST["login"])){ $_SESSION['komunikat'] = "Wpisz login i hasło:";
include('index.php');
}
else{
$val = checkPass($nick, $haslo);
if($val == 0){
$_SESSION['kiczarowo'] = $nick;
unSet($_SESSION['komunikat']); header("Location: index.php"); }
else if($val == 1){
$_SESSION['komunikat'] = "Błąd serwera.";
include('index.php');
}
else if($val == 2){
$_SESSION['komunikat'] = "Nieprawidłowy login lub hasło.";
include('index.php');
}
else{
$_SESSION['komunikat'] = "Błąd!";
include('index.php');
}
}
?>
Ten post edytował nikestylex7 27.02.2012, 21:59:57