Skip to content

Commit

Permalink
added logout
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Dec 18, 2010
1 parent 4278861 commit 0171a6e
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,18 @@
} else if ( ( isset($_POST['changepassword'] ) ) && ( $_POST['changepassword'] == "1" ) ) {
if ( isset($_POST['password1'],$_POST['password2']) && $_POST['password1'] == $_POST['password2'] ) {
$hash = md5( $salt. $_POST['password1'] );
if (!mysql_db_query("blog", "UPDATE TABLE posts SET password=$hash WHERE id=1")) die("Error changing password");
if (!mysql_db_query("blog", "UPDATE login SET pword='$hash' WHERE id=1")) die("Error changing password");

$status = "Password changed";

$_SESSION['loggedin'] = false;
$needlogin = true;
}
} else if ( ( isset($_POST['logout'] ) ) && ( $_POST['logout'] == "1" ) ) {
$status = "Logged out...";

$_SESSION['loggedin'] = false;
$needlogin = true;
}
}

Expand All @@ -46,7 +55,7 @@
<head><title>Blog Admin Page</title></head>
<body>
<?php
echo $status."<BR>";
if (isset($status)) echo $status."<BR>";

if ($needlogin === true ) {
?>
Expand All @@ -72,6 +81,10 @@
Confirm password:<input type="password" size="40" name="password2"><BR>
<input type="submit" value="Change password"><input type="hidden" name="changepassword" value="1">
</form>
Log out:
<form action="admin.php" method="POST">
<input type="submit" value="Log Out"><input type="hidden" name="logout" value="1">
</form>
<?php

}
Expand Down

0 comments on commit 0171a6e

Please sign in to comment.