Parašė avice· 2010 Gru. 24 20:12:49
#5
Taigi noriu pasidary login scriptuka simple:
<?php
if(isset($_COOKIE['username']) || $_COOKIE['password']){
$username = $_COOKIE['username'];
$password = $_COOKIE['password'];
if ($username == "test" && $password == "test"){
echo 'Prisijungiai Su Cookie ...';
echo 'Atsijungti <a href="out.php">here</a>';
}
}
if(isset($_POST['submit'])){
$username = $_POST['username'];
$password = $_POST['password'];
if ($username == "test" && $password == "test"){
setcookie("username", $username, time()+3600, "/");
setcookie("password", $password, time()+3600, "/");
echo 'Prisijungiai';
echo 'Atsijungti <a href="out.php">here</a>';
}
else {
echo 'Neteisigi Duomenys';
}
}
else {
if(!isset($_COOKIE['username'])){
echo '<form action="" method="POST">';
echo 'Username - <input name="username" type="text"><br />';
echo 'Password - <input name="password" type="password"><br />';
echo '<input name="submit" type="submit" value="Submit"><br />';
echo '</form>';
}
}
?>
Ir nelabai nusimanau apie cookies.
Ar sis budas saugus ar dar kokiu sudu reikia kist? ?|