index.php
CODE
<?php session_start();
echo '
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<META http-equiv=Content-Type content="text/html; charset=windows-1250">
<title>Logowanie</title>
<style type="text/css">
body { text-align: center;}
#CzarnyBlok { width: 200px; height: 200px; margin: auto; }
</style>
<script type="text/javascript">
function getPageSize(){
var yScroll;
if (window.innerHeight && window.scrollMaxY) {
yScroll = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
yScroll = document.body.scrollHeight;
} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
yScroll = document.body.offsetHeight;
}
var windowHeight;
if (self.innerHeight) { // all except Explorer
windowHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
windowHeight = document.documentElement.clientHeight;
} else if (document.body) { // other Explorers
windowHeight = document.body.clientHeight;
}
// for small pages with total height less then height of the viewport
if(yScroll < windowHeight){
pageHeight = windowHeight;
} else {
pageHeight = yScroll;
}
arrayPageSize = new Array(pageHeight,windowHeight)
return arrayPageSize;
}
function pobierz_wysokosc (){
var arrayPageSize = getPageSize();
var obiekt = document.getElementById("CzarnyBlok");
var wartosc = Math.round((arrayPageSize[0] - 200) / 2); // 100 to wysokosc naszego bloku
obiekt.style.marginTop = wartosc + "px";
}
window.onload = pobierz_wysokosc;
</script>
</head>
<body>
<div id="CzarnyBlok">
<table border="2" style="color:black;">
<tr><td bgcolor="#0A2850" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"align="center"><B style="COLOR: white;">Logowanie do systemu</td>
</tr>
<tr>
<td>
<form action="walidacja.php" method="post">
';
echo $_SESSION["tmp"];
echo '
<table style="FONT-SIZE: 14px; FONT-FAMILY: "Times New Roman"
bgcolor="#c5e4ed" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" align="center" >
<tr><td align="right"><B>Login:</B></td><td align="left"><input type="text" name="login" ></td></tr>
<tr><td align="right"><B>Hasło:</B></td><td align="left"><input type="password" name="haslo" ></td></tr>
<tr><td align="right"></td><td align="right"><input type="submit" name="tekst" value="Loguj"></td></tr>
</table>
</form>
</td>
</tr>
</table>
</div>
</body>
</html>
';
?>
echo '
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<META http-equiv=Content-Type content="text/html; charset=windows-1250">
<title>Logowanie</title>
<style type="text/css">
body { text-align: center;}
#CzarnyBlok { width: 200px; height: 200px; margin: auto; }
</style>
<script type="text/javascript">
function getPageSize(){
var yScroll;
if (window.innerHeight && window.scrollMaxY) {
yScroll = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
yScroll = document.body.scrollHeight;
} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
yScroll = document.body.offsetHeight;
}
var windowHeight;
if (self.innerHeight) { // all except Explorer
windowHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
windowHeight = document.documentElement.clientHeight;
} else if (document.body) { // other Explorers
windowHeight = document.body.clientHeight;
}
// for small pages with total height less then height of the viewport
if(yScroll < windowHeight){
pageHeight = windowHeight;
} else {
pageHeight = yScroll;
}
arrayPageSize = new Array(pageHeight,windowHeight)
return arrayPageSize;
}
function pobierz_wysokosc (){
var arrayPageSize = getPageSize();
var obiekt = document.getElementById("CzarnyBlok");
var wartosc = Math.round((arrayPageSize[0] - 200) / 2); // 100 to wysokosc naszego bloku
obiekt.style.marginTop = wartosc + "px";
}
window.onload = pobierz_wysokosc;
</script>
</head>
<body>
<div id="CzarnyBlok">
<table border="2" style="color:black;">
<tr><td bgcolor="#0A2850" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"align="center"><B style="COLOR: white;">Logowanie do systemu</td>
</tr>
<tr>
<td>
<form action="walidacja.php" method="post">
';
echo $_SESSION["tmp"];
echo '
<table style="FONT-SIZE: 14px; FONT-FAMILY: "Times New Roman"
bgcolor="#c5e4ed" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" align="center" >
<tr><td align="right"><B>Login:</B></td><td align="left"><input type="text" name="login" ></td></tr>
<tr><td align="right"><B>Hasło:</B></td><td align="left"><input type="password" name="haslo" ></td></tr>
<tr><td align="right"></td><td align="right"><input type="submit" name="tekst" value="Loguj"></td></tr>
</table>
</form>
</td>
</tr>
</table>
</div>
</body>
</html>
';
?>
i walidacja.php
CODE
<?php
if((empty($_POST['login']))OR($_POST['login']=="")){
$_SESSION['tmp']="mama"; header ("Location: index.php");
}
else{
if($_POST['haslo']==''){
$_SESSION["tmp"] = 'Proszę wprowadzić haslo';header ("Location: index.php");
}
else{
if(preg_match('/[A-Za-z]/',$login)){
if(preg_match('/[A-Za-z]/',$haslo)){
//laczenie z baza
$connection = @mysql_connect('localhost', 'root', '')
or die('Brak połaczenia z serwerem MySQL.<br />Bład: '.mysql_error());
$db = @mysql_select_db('superbaza', $connection)
or die('Nie mogę połaczyć się z baza danych<br />Bład: '.mysql_error());
//wyszukiwanie trzeba wpisac odpowiednie kolumny
$query = "SELECT *FROM osoby WHERE
(login LIKE '".$_POST["login"]."') AND
(haslo LIKE '".$_POST["haslo"]."')";
$wynik = mysql_query($query)
$num_rows = mysql_num_rows($wynik);
if($num_rows==0){ $_SESSION["tmp"]=$tmp;header ("Location: index.php");}
else{
// tu nalezy napisac przekirowanie co ma sie ma dziac po poprawnym wpisaniu loginu i hasla
// tu nalezy napisac przekirowanie co ma sie ma dziac po poprawnym wpisaniu loginu i hasla
// tu nalezy napisac przekirowanie co ma sie ma dziac po poprawnym wpisaniu loginu i hasla
}
}
}
}
}
?>
if((empty($_POST['login']))OR($_POST['login']=="")){
$_SESSION['tmp']="mama"; header ("Location: index.php");
}
else{
if($_POST['haslo']==''){
$_SESSION["tmp"] = 'Proszę wprowadzić haslo';header ("Location: index.php");
}
else{
if(preg_match('/[A-Za-z]/',$login)){
if(preg_match('/[A-Za-z]/',$haslo)){
//laczenie z baza
$connection = @mysql_connect('localhost', 'root', '')
or die('Brak połaczenia z serwerem MySQL.<br />Bład: '.mysql_error());
$db = @mysql_select_db('superbaza', $connection)
or die('Nie mogę połaczyć się z baza danych<br />Bład: '.mysql_error());
//wyszukiwanie trzeba wpisac odpowiednie kolumny
$query = "SELECT *FROM osoby WHERE
(login LIKE '".$_POST["login"]."') AND
(haslo LIKE '".$_POST["haslo"]."')";
$wynik = mysql_query($query)
$num_rows = mysql_num_rows($wynik);
if($num_rows==0){ $_SESSION["tmp"]=$tmp;header ("Location: index.php");}
else{
// tu nalezy napisac przekirowanie co ma sie ma dziac po poprawnym wpisaniu loginu i hasla
// tu nalezy napisac przekirowanie co ma sie ma dziac po poprawnym wpisaniu loginu i hasla
// tu nalezy napisac przekirowanie co ma sie ma dziac po poprawnym wpisaniu loginu i hasla
}
}
}
}
}
?>
Dlaczego one nie działają?
