Commit 28568c8f by Eirene Hutasoit

Menambahi

parent e3f271fa
<?php
session_start();
require_once 'core/init.php';
require_once 'fungsi.php';
require_once 'header.php';
if(!isset($_SESSION['user'])){
header("location: login.php");
}
if($_POST) {
$currentpassword = $_POST['currentpassword'];
$newpassword = $_POST['password'];
$conformpassword = $_POST['conformpassword'];
if($currentpassword == "") {
echo "Current Password field is required <br />";
}
if($newpassword == "") {
echo "New Password field is required <br />";
}
if($conformpassword == "") {
echo "Conform Password field is required <br />";
}
echo'<br>';
if($currentpassword && $newpassword && $conformpassword) {
if(passwordMatch($_SESSION['username'], $currentpassword) === TRUE) {
if($newpassword != $conformpassword) {
echo "New password does not match conform password <br />";
} else {
if(changePassword($_SESSION['username'], $newpassword) === TRUE) {
echo "Successfully updated";
} else {
echo "Error while updating the information <br />";
}
}
} else {
echo "Current Password is incorrect <br />";
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Change Password</title>
<meta charset="UTF-8" />
<link rel="shortcut icon" href="../favicon.ico">
<link rel="stylesheet" type="text/css" href="css/stylee.css" />
<link rel="stylesheet" type="text/css" href="css/animate-custom.css" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>BUKIT GIBEON</title>
<link rel="shortcut icon" href="images/inst.png">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/animate.css" rel="stylesheet">
<link href="css/myStyle.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="css/font-awesome.min.css">
<script src="js/jquery-3.1.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</head>
<body background="images/jay.jpg">
<section>
<div id="container_demo" >
<a class="hiddenanchor" id="toregister"></a>
<br><br><br><a class="hiddenanchor" id="tologin"></a>
<div id="wrapper">
<div id="login" class="animate form">
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST">
<div class="containers">
<h1>Change Password</h1>
<p>
<label for="username" class="uname" > Current Passowrd</label>
<input id="username" name="currentpassword" type="password" placeholder="enter username" required>
</p>
<p>
<label for="password" class="youpasswd" > New Password </label>
<input id="password" name="password" type="password" placeholder="enter passoword" required >
</p>
<p>
<label for="password" class="youpasswd" > Confirm Passord </label>
<input id="password" name="conformpassword" type="password" placeholder="enter passoword" required >
</p>
<p class="login button">
<input type="submit" value="Change" />
</p>
</form>
</div>
</form>
</body>
</html>
\ No newline at end of file
<?php
$servername = "127.0.0.1";
$username = "root";
$password = "";
$dbname = "p1d3ti08_proyek";
// crearte connection
$connect = new Mysqli($servername, $username, $password, $dbname);
// check connection
if($connect->connect_error) {
die("Connection Failed : " . $connect->error);
} else {
// echo "Successfully Connected";
}
?>
\ No newline at end of file
<?php
require_once 'db_connect.php';
require_once 'users.php';
?>
\ No newline at end of file
<?php
include_once'fungsi.php';
function userExists($username) {
// global keywords is used to access a global variable from within a function
global $connect;
$sql = "SELECT * FROM user WHERE username = '$username'";
$query = $connect->query($sql);
if($query->num_rows == 1) {
return true;
} else {
return false;
}
$connect->close();
// close the database connection
}
function registerUser() {
global $connect;
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$username = $_POST['username'];
$password = $_POST['password'];
$salt = salt(32);
$newPassword = makePassword($password, $salt);
if($newPassword) {
$sql = "INSERT INTO user (namalengkap, alamat, email, username, password) VALUES ('$fname', '$lname', '$username', '$newPassword', '$salt' , 1)";
$query = $connect->query($sql);
if($query === TRUE) {
return true;
} else {
return false;
}
} // /if
$connect->close();
// close the database connection
} // register user funtion
function salt($length) {
return mcrypt_create_iv($length);
}
function makePassword($password, $salt) {
return hash('sha256', $password.$salt);
}
function userdata($username) {
global $connect;
$sql = "SELECT * FROM user WHERE username = '$username'";
$query = $connect->query($sql);
$result = $query->fetch_assoc();
if($query->num_rows == 1) {
return $result;
} else {
return false;
}
$connect->close();
// close the database connection
}
function login($username, $password) {
global $connect;
$userdata = userdata($username);
if($userdata) {
$makePassword = makePassword($password, $userdata['salt']);
$sql = "SELECT * FROM user WHERE username = '$username' AND password = '$makePassword'";
$query = $connect->query($sql);
if($query->num_rows == 1) {
return true;
} else {
return false;
}
}
$connect->close();
// close the database connection
}
function getUserDataByUserId($username) {
global $connect;
$sql = "SELECT * FROM user WHERE username = '$username'";
$query = $connect->query($sql);
$result = $query->fetch_assoc();
return $result;
$connect->close();
}
function user_exists_by_id($id, $username) {
global $connect;
$sql = "SELECT * FROM user WHERE username = '$username' AND id != $id";
$query = $connect->query($sql);
if($query->num_rows >= 1) {
return true;
} else {
return false;
}
$connect->close();
}
function updateInfo($id) {
global $connect;
$username = $_POST['username'];
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$contact = $_POST['contact'];
$address = $_POST['address'];
$sql = "UPDATE user SET username = '$username', namalengkap = '$fname', alamat = '$lname', email = '$address' WHERE id = $id";
$query = $connect->query($sql);
if($query === TRUE) {
return true;
} else {
return false;
}
}
function logged_in() {
if(isset($_SESSION['id'])) {
return true;
} else {
return false;
}
}
function not_logged_in() {
if(isset($_SESSION['id']) === FALSE) {
return true;
} else {
return false;
}
}
function logout() {
if(logged_in() === TRUE){
// remove all session variable
session_unset();
// destroy the session
session_destroy();
header('location: login.php');
}
}
function passwordMatch($username, $password) {
global $connect;
$userdata = getUserDataByUserId($username);
$makePassword = $password;
if($makePassword == $userdata['password']) {
return true;
} else {
return false;
}
// close connection
$connect->close();
}
function changePassword($username, $password) {
global $connect;
$makePassword = $password;
$sql = "UPDATE user SET password = '$makePassword' WHERE username = '$username'";
$query = $connect->query($sql);
if($query === TRUE) {
return true;
} else {
return false;
}
}
/*
Zebra_DatePicker: a lightweight jQuery date picker plugin
Default theme
copyright (c) 2011 - 2013 Stefan Gabos
http://stefangabos.ro/jquery/zebra-datepicker/
*/
.Zebra_DatePicker * { margin: 0; padding: 0; color: #000 }
.Zebra_DatePicker { position: absolute; background: #666; border: 3px solid #666; display: none; z-index: 100; font-family: Tahoma, Arial, Helvetica, sans-serif; font-size: 13px }
/* = GLOBALS
----------------------------------------------------------------------------------------------------------------------*/
.Zebra_DatePicker table { border-collapse: collapse; border-spacing: 0 }
.Zebra_DatePicker td,
.Zebra_DatePicker th { text-align: center; padding: 5px 0 }
.Zebra_DatePicker td { cursor: pointer }
.Zebra_DatePicker .dp_daypicker,
.Zebra_DatePicker .dp_monthpicker,
.Zebra_DatePicker .dp_yearpicker { margin-top: 3px }
.Zebra_DatePicker .dp_daypicker td,
.Zebra_DatePicker .dp_daypicker th,
.Zebra_DatePicker .dp_monthpicker td,
.Zebra_DatePicker .dp_yearpicker td { background: #E8E8E8; width: 30px; border: 1px solid #7BACD2 }
.Zebra_DatePicker,
.Zebra_DatePicker .dp_header .dp_hover,
.Zebra_DatePicker .dp_footer .dp_hover { -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px }
/* = HEADER
----------------------------------------------------------------------------------------------------------------------*/
.Zebra_DatePicker .dp_header td { color: #FFF }
.Zebra_DatePicker .dp_header .dp_previous,
.Zebra_DatePicker .dp_header .dp_next { width: 30px }
.Zebra_DatePicker .dp_header .dp_caption { font-weight: bold }
.Zebra_DatePicker .dp_header .dp_hover { background: #222; color: #FFF }
.Zebra_DatePicker .dp_header .dp_blocked { color: #888; cursor: default }
/* = DATEPICKER
----------------------------------------------------------------------------------------------------------------------*/
.Zebra_DatePicker .dp_daypicker th { background: #FFCC33 }
.Zebra_DatePicker td.dp_not_in_month { background: #F3F3F3; color: #CDCDCD; cursor: default }
.Zebra_DatePicker td.dp_not_in_month_selectable { background: #F3F3F3; color: #CDCDCD; cursor: pointer }
.Zebra_DatePicker td.dp_weekend { background: #D8D8D8 }
.Zebra_DatePicker td.dp_weekend_disabled { color: #CCC; cursor: default }
.Zebra_DatePicker td.dp_selected { background: #5A4B4B; color: #FFF !important }
.Zebra_DatePicker td.dp_week_number { background: #FFCC33; color: #555; cursor: text; font-style: italic }
/* = MONTHPICKER
----------------------------------------------------------------------------------------------------------------------*/
.Zebra_DatePicker .dp_monthpicker td { width: 33% }
/* = YEARPICKER
----------------------------------------------------------------------------------------------------------------------*/
.Zebra_DatePicker .dp_yearpicker td { width: 33% }
/* = FOOTER
----------------------------------------------------------------------------------------------------------------------*/
.Zebra_DatePicker .dp_footer { margin-top: 3px }
.Zebra_DatePicker .dp_footer td { color: #FFF; padding: 2px; font-weight: bold }
.Zebra_DatePicker .dp_footer .dp_hover { background: #222; color: #FFF }
/* = SOME MORE GLOBALS (MUST BE LAST IN ORDER TO OVERWRITE PREVIOUS PROPERTIES)
----------------------------------------------------------------------------------------------------------------------*/
.Zebra_DatePicker td.dp_current { color: #C40000 }
.Zebra_DatePicker td.dp_disabled_current { color: #E38585 }
.Zebra_DatePicker td.dp_disabled { background: #F3F3F3; color: #CDCDCD; cursor: default }
.Zebra_DatePicker td.dp_hover { background: #482424; color: #FFF }
/* = ICON
----------------------------------------------------------------------------------------------------------------------*/
button.Zebra_DatePicker_Icon { position: relative; display: inline-block; width: 16px; height: 16px; background: url('calendar.png') no-repeat left top; text-indent: -9000px; border: none; cursor: pointer; padding: 0; line-height: 0; vertical-align: top; *display: inline; zoom: 1 }
button.Zebra_DatePicker_Icon_Disabled { background-image: url('calendar-disabled.png') }
/* don't set vertical margins! */
button.Zebra_DatePicker_Icon { margin: 0 0 0 3px }
button.Zebra_DatePicker_Icon_Inside { margin: 0 3px 0 0 }
\ No newline at end of file
/*
Zebra_DatePicker: a lightweight jQuery date picker plugin
Metalic Theme
copyright (c) 2011 - 2013 Stefan Gabos
http://stefangabos.ro/jquery/zebra-datepicker/
*/
.Zebra_DatePicker * { margin: 0; padding: 0; color: #666 }
.Zebra_DatePicker { position: absolute; background: #373737; border: 3px solid #373737; display: none; z-index: 100; font-family: Geneva, 'Lucida Sans', 'Lucida Grande', 'Lucida Sans Unicode', Verdana, sans-serif; font-size: 13px }
/* = GLOBALS
----------------------------------------------------------------------------------------------------------------------*/
.Zebra_DatePicker table { border-collapse: collapse; border-spacing: 0 }
.Zebra_DatePicker td,
.Zebra_DatePicker th { text-align: center; padding: 5px 0 }
.Zebra_DatePicker td { cursor: pointer }
.Zebra_DatePicker .dp_daypicker,
.Zebra_DatePicker .dp_monthpicker,
.Zebra_DatePicker .dp_yearpicker { margin-top: 3px }
.Zebra_DatePicker .dp_daypicker td,
.Zebra_DatePicker .dp_daypicker th,
.Zebra_DatePicker .dp_monthpicker td,
.Zebra_DatePicker .dp_yearpicker td { width: 30px; border: 1px solid #BBB; background: #DEDEDE url('metallic/default-date.png') repeat-x top; color: #666 }
.Zebra_DatePicker,
.Zebra_DatePicker .dp_header .dp_hover { -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px }
/* = HEADER
----------------------------------------------------------------------------------------------------------------------*/
.Zebra_DatePicker .dp_header td { color: #E0E0E0 }
.Zebra_DatePicker .dp_header .dp_previous,
.Zebra_DatePicker .dp_header .dp_next { width: 30px }
.Zebra_DatePicker .dp_header .dp_caption { font-weight: bold }
.Zebra_DatePicker .dp_header .dp_hover { background: #67AABB; color: #FFF }
.Zebra_DatePicker .dp_header .dp_blocked { color: #888; cursor: default }
/* = DATEPICKER
----------------------------------------------------------------------------------------------------------------------*/
.Zebra_DatePicker td.dp_week_number,
.Zebra_DatePicker .dp_daypicker th { background: #F1F1F1 url('metallic/titles.png') repeat-x top; font-size: 9px; padding-top: 7px }
.Zebra_DatePicker td.dp_weekend_disabled,
.Zebra_DatePicker td.dp_not_in_month,
.Zebra_DatePicker td.dp_not_in_month_selectable { background: #ECECEC url('metallic/disabled-date.png'); color: #CCC; cursor: default }
.Zebra_DatePicker td.dp_not_in_month_selectable { cursor: pointer }
.Zebra_DatePicker td.dp_weekend { background: #DEDEDE url('metallic/default-date.png') repeat-x top; color: #666 }
.Zebra_DatePicker td.dp_selected { background: #E26262; color: #E0E0E0 !important }
/* = MONTHPICKER
----------------------------------------------------------------------------------------------------------------------*/
.Zebra_DatePicker .dp_monthpicker td { width: 33% }
/* = YEARPICKER
----------------------------------------------------------------------------------------------------------------------*/
.Zebra_DatePicker .dp_yearpicker td { width: 33% }
/* = SOME MORE GLOBALS (MUST BE LAST IN ORDER TO OVERWRITE PRESIOUS PROPERTIES)
----------------------------------------------------------------------------------------------------------------------*/
.Zebra_DatePicker td.dp_current { color: #E26261 }
.Zebra_DatePicker td.dp_disabled_current { color: #E38585 }
.Zebra_DatePicker td.dp_hover { background: #67AABB url('metallic/selected-date.png') repeat-x top; color: #FFF }
.Zebra_DatePicker td.dp_disabled { background: #ECECEC url('metallic/disabled-date.png') repeat-x top; color: #DDD; cursor: default }
/* = ICON
----------------------------------------------------------------------------------------------------------------------*/
/* = ICON
----------------------------------------------------------------------------------------------------------------------*/
button.Zebra_DatePicker_Icon { position: relative; display: inline-block; width: 16px; height: 16px; background: url('calendar.png') no-repeat left top; text-indent: -9000px; border: none; cursor: pointer; padding: 0; line-height: 0; vertical-align: top; *display: inline; zoom: 1 }
button.Zebra_DatePicker_Icon_Disabled { background-image: url('calendar-disabled.png') }
/* don't set vertical margins! */
button.Zebra_DatePicker_Icon { margin: 0 0 0 3px }
button.Zebra_DatePicker_Icon_Inside { margin: 0 3px 0 0 }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment