Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Problem z logowaniem
funky_beat
post
Post #1





Grupa: Zarejestrowani
Postów: 63
Pomógł: 0
Dołączył: 24.05.2007
Skąd: Bełchatów

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


Witam,

Kolejny problem dotyczy logowania.

Stworzylem taki skrypt:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250" />
<title>Witaj na stronie SGM</title>
</head>
<body>

<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);


include ('naglowek.inc');

ob_start();
require_once('baza.php'); // załaczamy plik baza.php

function usun($data){

GLOBAL $dbc;
if (ini_get('magic_quotes_gpc')){
$data = stripslashes($data);
}
return mysql_real_escape_string($data, $dbc);
}
if (isset($_POST['submit'])){

if (empty($_POST['Login'])){
$message .= '<font class="blad" color="red">Nie podałeś loginu</font><br />';
$l = FALSE;
}else{
$l = usun($_POST['Login']);
}

if (empty($_POST['Haslo'])){
$message .= '<font class="blad" color="red">Nie podałeś hasła</font><br />';
$p = FALSE;
}else{
$p = usun($_POST['Haslo']);
}
if ( $l && $p ){

$query = "SELECT 'Login', 'Imie' FROM 'pracownicy' WHERE 'Login'='$l' AND 'Haslo'=PASSWORD('$p')";
$result = mysql_query($query);

echo $query.'<br/>';
echo mysql_error();

$row = mysql_fetch_array ($result, MYSQL_ASSOC);
if($row){
session_start();
$_SESSION['Login'] = $row['0'];
$_SESSION['Imie'] = $row['1'];
$_POST['cmd'] = 'ok';
header ("Location: ind.php?cmd={$_POST['cmd']}"); // przekierowuje nas na jaka strone chcemy
}else{




$message .= '<font class="blad" color="red">Błędne hasło lub login</font><br />';
}

mysql_close();
}else{
$message .= '<font class="blad">Spróbuj jeszcze raz</font>';
}
}
ob_end_flush();


//mysql_error()
//mysql_num_rows()

?>



<div style="text-align: center;">Logowanie do SGM<br /><br /><br />
<form method="post" action="<? echo $_SERVER['PHP_SELF']; ?>">

<fieldset>

<legend align="bottom">Podaj swój Login Pracownika i Hasło</legend>

<p><b>Login:</b> <input type="text" name="Login" size="20" maxlength="20" value="<?php if (isset($_POST['Login'])) echo $_POST['Login']; ?>" /></p>

<p><b>Haslo:</b> <input type="password" name="Haslo" size="20" maxlength="10" /></p>

</fieldset>

<br /><input name="submit" value="Zaloguj" type="submit" />

</div>
<br />
</form>


<div align="center">
<? if(isset($message)){
echo $message;
}
?>
</div>


<?php
include ('stopka.inc');

?>
</body>
</html>






Przy próbie logowania wyskakuje mi błąd:



SELECT 'Login', 'Imie' FROM 'pracownicy' WHERE 'Login'='111' AND 'Haslo'=PASSWORD('222')
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ''pracownicy' WHERE 'Login'='111' AND 'Haslo'=PASSWORD('222')' a Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\apache2\htdocs\www\logon1.php on line 51 Notice: Undefined variable: message in C:\apache2\htdocs\www\logon1.php on line 63




Prosze o pomoc juz dwa tygodnie z tym walcze i nic (IMG:http://forum.php.pl/style_emoticons/default/sad.gif)
Go to the top of the page
+Quote Post

Posty w temacie


Closed TopicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 23.08.2025 - 16:16