Skip to content

Commit

Permalink
#77
Browse files Browse the repository at this point in the history
change password update
  • Loading branch information
LinZhihaozlin22 authored Nov 14, 2019
1 parent b6de2fe commit ea5cbf6
Show file tree
Hide file tree
Showing 3 changed files with 141 additions and 1 deletion.
32 changes: 32 additions & 0 deletions alterpassword.handle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
session_start ();
require_once('setting/server_config.php');
$AccountTable_name= "useraccount";
$useremail = $_REQUEST ["useremail"];
$oldpassword = $_REQUEST ["oldpassword"];
$newpassword = $_REQUEST ["newpassword"];


$retusername = null;
$retpassword = null;
$result = mysqli_query ($conn, "SELECT * FROM $AccountTable_name WHERE User_email ='$useremail';");
while ( $row = mysqli_fetch_array ( $result ) ) {
$retuseremail = $row ["User_email"];
$retpassword = $row ["User_Password"];
}

if (is_null ( $retuseremail )) {
echo "<script>alert('email does not exist'); window.location.href='alterpassword.php' </script>";
exit();
}

if ($oldpassword != $retpassword) {
echo "<script>alert('old password wrong'); window.location.href='alterpassword.php' </script>";
exit();
}
mysqli_query ($conn, "UPDATE $AccountTable_name SET User_password='$newpassword' WHERE User_email='$useremail'" );
mysqli_close ( $conn );

header('Location: index.php');
echo "password change successfully";
?>
81 changes: 81 additions & 0 deletions alterpassword.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<!--
Author: W3layouts
Author URL: http://w3layouts.com
License: Creative Commons Attribution 3.0 Unported
License URL: http://creativecommons.org/licenses/by/3.0/
-->
<!DOCTYPE html>
<?php
session_start();
?>
<html>
<head>
<title>UB TRADE</title>
<link rel="stylesheet" href="css/bootstrap.min.css"><!-- bootstrap-CSS -->
<link href="css/style.css" rel="stylesheet" type="text/css" media="all" /><!-- style.css -->
<link rel="stylesheet" href="css/font-awesome.min.css" /><!-- fontawesome-CSS -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- header -->
<header>
<div class="w3ls-header"><!--header-one-->
<div class="w3ls-header-right">
<ul>
<li class="dropdown head-dpdn">
<a href="signin_front.php" aria-expanded="false"><i class="fa fa-user" aria-hidden="true"></i>
<a>
<?php if (isset($_SESSION['username']))
{
echo $_SESSION['username'];
} else echo"Sign In"?></a>
</li>
</ul>
</div>

<div class="clearfix"> </div>
</div>
<div class="container">
<div class="agile-its-header">
<div class="logo">
<h1><a href="index.php"><span>UB</span>TRADE</a></h1>
</div>
<div class="agileits_search">
<a class="post-w3layouts-ad" href="index.php">Back to Homepage</a>
</div>
<div class="clearfix"></div>
</div>
</div>
</header>
<!-- //header -->
<!-- sign in form -->
<section>
<div id="agileits-sign-in-page" class="sign-in-wrapper">
<div class="agileinfo_signin">
<h3>Account information</h3>
<form action="alterpassword.handle.php" method="post">
<input type="email" name="useremail" placeholder="Your_Email" required="">
<input type="password" name="oldpassword" placeholder="Old Password" required="">
<input type="password" name="newpassword" placeholder="New Password" required="">
<input type="submit" value="Submit Change">
</form>
</div>
</div>
</section>
<!-- //sign in form -->
<!--footer section start-->
<footer>
<div class="agileits-footer-bottom text-center">
<div class="container">
<div class="w3-footer-logo">
<h1><a href="index.php"><span>UB</span>TRADE</a></h1>
</div>
<div class="copyrights">
<p> Design by <label> CSE_442_TEAM</label></p>
</div>
<div class="clearfix"></div>
</div>
</div>
</footer>
<!--footer section end-->


</html>
29 changes: 28 additions & 1 deletion manage.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
<div class="w3ls-header"><!--header-one-->
<div class="w3ls-header-right">
<ul>
<!-- click to change password-->
<li class="dropdown head-dpdn">
<a href="alterpassword.php"><i aria-hidden="true"></i> Change Password </a>
</li>
<!-- change password end-->
<!-- click to sign out account -->
<li class="dropdown head-dpdn">
<a href="setting/Sign_Out.php"><i aria-hidden="true"></i> Sign Out</a>
Expand Down Expand Up @@ -77,17 +82,39 @@
<div role="tabpanel" class="tab-pane fade in active" id="home" aria-labelledby="home-tab">
<div>
<div id="container">
<div class="sort">
<div class="sort-by">
<label>Sort By : </label>
<form method="GET">
<select name = "orderby" onchange="this.form.submit()"> <!-- every time when select, pass the "order way" to get and refresh page with updated order way-->
<option hidden><?php if(isset($_GET['orderby'])){
if($_GET['orderby'] =="Release_date DESC" ) {echo "Most recent";}
else if ($_GET['orderby'] =="Price DESC" ) {echo "Price: High to Low";}
else if ($_GET['orderby'] =="Price ASC" ) {echo "Price: Low to High";}
} else echo"Most recent";
?></option>
<option value="Release_date DESC">Most recent</option>
<option value="Price ASC">Price: Low to High</option>
<option value="Price DESC">Price: High to Low</option>
</select>
</form>
</div>
</div>

<div class="clearfix"></div>
<br>
<ul class="list">
<!--implementing display_method:
display all products in database to front site with its' information
in section format-->
<?php
if(isset($_GET['orderby'])){ //set the default order way to be "recent_upload"
$ordby = $_GET['orderby'];
} else { $ordby = "Release_date DESC"; }
if (isset($_SESSION['username']))
{
$un=$_SESSION['username'];
$query = "SELECT * FROM product WHERE User_name = '".$un."' ORDER BY Release_date DESC";
$query = "SELECT * FROM product WHERE User_name = '".$un."' ORDER BY $ordby";
} else echo "<script>alert('Please sign in frist'); window.location.href='index.php' </script>";
$result = mysqli_query($conn, $query);
while($row = mysqli_fetch_assoc($result)){
Expand Down

0 comments on commit ea5cbf6

Please sign in to comment.