De code nu:
Ik wil dat er staat gewoon een button: Uitloggen en dat de PC kiest voor Alle PCs
Ik heb met dit geprobeerd maar het lukt eniet.
Kan iemand me helpen?
if(!$_POST[logout]) {
$count_sessions = mysql_query("SELECT COUNT(*) FROM sessions WHERE userid = ".sqlsafe($_COOKIE[id])." ");
$sessionscounted = mysql_result($count_sessions,0);
if ($sessionscounted == 1) { $browserstring = "browser"; } else { $browserstring = "browsers"; }
echo "<p>Je bent op dit moment ingelogd op <b>".$sessionscounted."</b> ".$browserstring.".<br />Maak een keuze uit een van de volgende opties:</p>";
echo "<form method="POST" action="">";
echo "<input name="logoutmode" type="radio" value="onlythissession">Alleen deze PC.<br />";
echo "<input name="logoutmode" type="radio" value="allsessions">Alle PCs.<br />";
echo "<input name="logoutmode" type="radio" value="choosesession" id="logout_by_session">Kies een sessie:<br />";
echo "<table border="1">";
?>
<tr>
<td> </td>
<td>SessID</td>
<td>Datum / tijd</td>
</tr>
[COLOR= #0000BB]<?php
$sessioninfo[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM sessions WHERE userid = "[/COLOR][COLOR= #007700].[/COLOR]sqlsafe[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_COOKIE[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sessions[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sessioninfo[/COLOR][COLOR= #007700])){[/COLOR]
?>
<tr>
<td><input name="sessionid[]" type="checkbox" value="[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$sessions[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]hash[/COLOR][COLOR= #007700]];[/COLOR]?>" onChange="document.getElementById(logout_by_session).checked = true"></td>
<td>[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$sessions[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]hash[/COLOR][COLOR= #007700]];[/COLOR]?></td>
<td>[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$sessions[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]logintime[/COLOR][COLOR= #007700]];[/COLOR]?></td>
</tr>
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #007700]}[/COLOR]
?>
</table>
<input type="submit" name="logout" value="Uitloggen">
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"</form>"[/COLOR][COLOR= #007700];
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]logoutmode[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]"onlythissession"[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"DELETE FROM sessions WHERE hash = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_COOKIE[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]hash[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]" "[/COLOR][COLOR= #007700])) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Je huidige sessie is uitgelogd"[/COLOR][COLOR= #007700];
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Je sessie is niet uitgelogd wegens een fout:<br />"[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]();
}
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]logoutmode[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]"allsessions"[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"DELETE FROM sessions WHERE userid = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_COOKIE[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]" "[/COLOR][COLOR= #007700])) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Al je sessies zijn nu uitgelogd"[/COLOR][COLOR= #007700];
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Je sessies zijn niet uitgelogd wegens een fout:<br />"[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]();
}
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]logoutmode[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]"allothersession"[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Deze functie werkt nog niet."[/COLOR][COLOR= #007700];
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]logoutmode[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]"choosesession"[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Je geselecteerde sessie(s) zijn nu uitgelogd"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/foreach"]foreach[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]sessionid[/COLOR][COLOR= #007700]] as[/COLOR] [COLOR= #0000BB]$index[/COLOR] [COLOR= #007700]=>[/COLOR] [COLOR= #0000BB]$sessid[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"DELETE FROM sessions WHERE hash = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$sessid[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]" "[/COLOR][COLOR= #007700])) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Je sessie is niet uitgelogd wegens een fout:<br />"[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]();
}
}
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700](![/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]logoutmode[/COLOR][COLOR= #007700]]) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Je ben vergeten een keuze te maken uit de uitlogopties."[/COLOR][COLOR= #007700];
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Deze uitlogoptie is niet bekend."[/COLOR][COLOR= #007700];
}
}
}[/COLOR]
?> Ik wil dat er staat gewoon een button: Uitloggen en dat de PC kiest voor Alle PCs
Ik heb met dit geprobeerd maar het lukt eniet.
Kan iemand me helpen?
.
sessioninfo = mysql_query("SELECT * FROM sessions WHERE userid = ".sqlsafe($_COOKIE[id])."");