tusim ze v tom prvok phpcku to nebude
Kód:
main_login.php
Kód: Vybrať všetko
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
<title>Prihlasenie</title>
</head>
<body bgcolor="#000000">
<table border="0" width="100%" height="454">
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>
<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form name="form1" method="post" action="checklogin.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#000000">
<tr>
<td colspan="3"> <strong> <font color="#E2E2E2">Prihlásenie užívate¾a </ strong> </ td>
</ Tr> </font>
<tr>
<td width="78"> <font color="#E2E2E2">Meno </ td> </font>
<td width="6"><font color="#E2E2E2">: </ td> </font>
<td width="294"> <font color="#E2E2E2"> <input name="myusername" type="text" id="myusername"> </ td>
</ Tr> </font>
<tr>
<td> <font color="#E2E2E2">Heslo </ td> </font>
<td><font color="#E2E2E2">: </ td> </font>
<td> <font color="#E2E2E2"> <input name="mypassword" type="text" id="mypassword"> </ td>
</ Tr> </font>
<tr>
<td> <font color="#E2E2E2"></ td> </font>
<td> <font color="#E2E2E2"></ td> </font>
<td> <font color="#E2E2E2"> <input type="submit" name="submit" value="Login"> </ td>
</ Tr>
</ Table>
</ Td>
</ Form>
</ Tr>
</ Table> </font></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html>checklogin.php
Kód: Vybrať všetko
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
<title>Nová stránka 1</title>
</head>
<body>
<?php
$host="localhost";
$username="prezyvka";
$password="heslo";
$db_name="databaza";
$tbl_name="tabulka";
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$encrypted_mypassword=md5($mypassword);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$encrypted_mypassword'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1){
session_register("myusername");
session_register("mypassword");
header ( "location: login_success.php");
}
else {
echo "Wrong Username or Password";
}
?>
</body>
</html>
Kód: Vybrať všetko
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
<title>Login Successful</title>
<?
session_start();
if(!session_is_registered(myusername)){
header("location:main_login.php");
}
?>
</head>
<body>
Login Successful
</body>
</html