PHP expert |
|
met mijn login script roep ik zo de cookies aan
setcookie('id', $user['id'], time()+(60*60*24*5), '/');
setcookie('password', $user['password'], time()+(60*60*24*5), '/');
setcookie('password', $user['password'], time()+(60*60*24*5), '/');
en met logout verwijder ik het zo (hele pagina, omdat die kleiner is en misschien ziet hier iemand een fout )
<form method="post">
<table width="400">
<?php
include("config.php");
if (!isset($logged[username])) {
echo "<td colspan='2'>You have to be logged in to logout</td>";
}else{
?>
<tr>
<td colspan="2">Are you sure, you want to logout?</td>
</tr>
<tr>
<td><input type="submit" name="yes" value="Yes"></td><td><input type="submit" name="no" value="No"></td>
</tr>
<?
if(isset($_POST['yes'])) {
setcookie('id', '', time() -1);
setcookie('password', '', time() -1);
echo "<td colspan='2'>You are logged out</td>";
}
if(isset($_POST['no'])) {
echo ("<meta http-equiv=\"Refresh\" content=\"2; URL=members/home.php\"/><td colspan='2'>You will be redirecting</td>");
}
}
?>
</table>
</form>
<form method="post"> <table width="400"> <?php include("config.php"); if (!isset($logged[username ])) { echo "<td colspan='2'>You have to be logged in to logout</td>"; }else{ ?> <tr> <td colspan="2">Are you sure, you want to logout?</td> </tr> <tr> <td><input type="submit" name="yes" value="Yes"></td><td><input type="submit" name="no" value="No"></td> </tr> <? if(isset($_POST['yes'])) { echo "<td colspan='2'>You are logged out</td>"; } if(isset($_POST['no'])) { echo ("<meta http-equiv=\"Refresh\" content=\"2; URL=members/home.php\"/><td colspan='2'>You will be redirecting</td>"); } } ?> </table> </form>
$logged[] komt uit config:
$logged = mysql_query("SELECT * FROM users WHERE id='$_COOKIE[id]' AND password = '$_COOKIE[password]'") or die(mysql_error());
$logged = mysql_fetch_array($logged, MYSQL_ASSOC);
$logged = mysql_query("SELECT * FROM users WHERE id='$_COOKIE[id]' AND password = '$_COOKIE[password]'") or die(mysql_error());
iemand tje
|