Server : LiteSpeed System : Linux us-phx-web1202.main-hosting.eu 4.18.0-553.84.1.lve.el8.x86_64 #1 SMP Tue Nov 25 18:33:03 UTC 2025 x86_64 User : u615232177 ( 615232177) PHP Version : 8.1.33 Disable Function : NONE Directory : /home/u615232177/public_html/ |
<?php session_start();
$page_name = basename($_SERVER['PHP_SELF']);
include("headerstrict.php"); ?>
<title><?php echo $company_name; ?> - Your Account</title>
<?php
$stmt = $con -> prepare('SELECT * FROM users WHERE user_id=?');
$stmt -> bind_param('s',$user_id);
$stmt -> execute();
$stmt -> store_result();
$stmt -> bind_result($id,$user_id,$first_name,$last_name,$email,$password,$phone,$address,$date_signed_up);
$numrows = $stmt -> num_rows();
if($numrows > 0){
while ($stmt -> fetch()) {
}
}
else{echo "<meta http-equiv=\"refresh\" content=\"0; url=index.php\">";exit();}
?>
<!-- Start All Title Box -->
<div class="all-title-box">
<div class="container">
<div class="row">
<div class="col-lg-12">
<h2>Your Account</h2>
<ul class="breadcrumb">
<li class="breadcrumb-item"><a href="#">Home</a></li>
<li class="breadcrumb-item active">Your Account</li>
</ul>
</div>
</div>
</div>
</div>
<!-- End All Title Box -->
<?php
if (isset($_POST['save_changes'])){
$phone = mysqli_real_escape_string($con,$_POST['phone']);
$address = mysqli_real_escape_string($con,$_POST['address']);
$stmt = $con -> prepare('UPDATE users SET phone = ?,address = ? WHERE user_id = ?');
$stmt -> bind_param('sss', $phone,$address,$user_id);
$stmt -> execute();
//create a session to verify it's coming from here
$_SESSION["action"] = "true";
$message="Update was successfully done.";
echo "<meta http-equiv=\"refresh\" content=\"0; url=success.php?u=$page_name&m=$message\">";
}
?>
<div class="checkout">
<div class="container">
<div class="row">
<div class="col-lg-6">
<div class="billing"><br/><br/>
<div class="checkout_title">Wallet</div>
Fund your wallet for a faster shopping experience.
<?php
//get wallet balance
$total_wallet=0; $success = "Success"; $failed = "Failed";
$stmt_withdraw = $con -> prepare('SELECT * FROM wallet WHERE user_id = ? AND status = ?');
$stmt_withdraw -> bind_param('ss',$user_id,$success);
$stmt_withdraw -> execute();
$stmt_withdraw -> store_result();
$stmt_withdraw -> bind_result($w_id,$wallet_id,$user_id,$order_id,$wallet_amount,$amount_remaining,$wallet_type,$wallet_action,$wallet_status,$wallet_date);
$numrows_withdraw = $stmt_withdraw -> num_rows();
if($numrows_withdraw > 0){
while ($stmt_withdraw -> fetch()) {
if($wallet_type == "Credit"){
$total_wallet += $wallet_amount;
}
if($wallet_type == "Debit"){
$total_wallet -= $wallet_amount;
}
}
}
echo"<div style='height:20px;'></div>
<h2> Your current balance is <span style='font-weight:900;'>";
echo $currency; echo number_format((float)$total_wallet, 2, '.', ',');
echo"</span></h2>";
?>
<hr>
Fund your wallet
<form class="form-contact contact_form" action="fund_wallet.php" method='post' id="contactForm1">
<div class="row">
<div class="col-sm-12">
<div class="form-group">
<input class="form-control valid" name="fund_amount" required id="" type="number" min='1' onfocus="this.placeholder = ''" onblur="this.placeholder = 'Amount'" placeholder="Amount (Minimum of 1 NGN)">
</div>
<div class="form-group">
<select class="form-control valid" name="account" required>
<option value="">Choose a payment method</option>
<option value="Opay">Opay</option>
<option value="Fidelity">Fidelity</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<button type="submit" name='fund_wallet' class="btn hvr-hover" style='color:white;'>Fund</button>
</div>
</form>
</div>
</div>
<div class="col-lg-6">
<div class="billing"><br/><br/>
<div class="checkout_title">Account Details</div>
<?php if(isset($_SESSION["user_id"])){ ?>
You may edit your shipping address and phone number<br/><br/>
<?php } ?>
<form class="form-contact contact_form" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method='post' id="contactForm">
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<input class="form-control valid" name="first_name" required id="" type="text" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Enter your first name'" placeholder="Enter your first name" value='<?php echo $first_name; ?>' <?php if(isset($_SESSION["user_id"])){ ?> readonly <?php } ?>>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<input class="form-control valid" name="last_name" required id="" type="text" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Enter your last name'" placeholder="Enter your last name" value='<?php echo $last_name; ?>' <?php if(isset($_SESSION["user_id"])){ ?> readonly <?php } ?>>
</div>
</div>
<div class="col-sm-12">
<div class="form-group">
<input class="form-control valid" name="email" required id="email" type="email" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Email address'" placeholder="Email" value='<?php echo $email; ?>'<?php if(isset($_SESSION["user_id"])){ ?> readonly <?php } ?>>
</div>
</div>
<div class="col-sm-12">
<div class="form-group">
<input class="form-control valid" name="address" required id="" type="text" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Address'" placeholder="Address" value='<?php echo $address; ?>'>
</div>
</div>
<div class="col-sm-12">
<div class="form-group">
<input class="form-control valid" name="phone" required id="" type="text" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Phone'" placeholder="Phone" value='<?php echo $phone; ?>'>
</div>
</div>
</div>
<div class="form-group">
<button type="submit" name='save_changes' class="btn hvr-hover" style='color:white;'>Save Changes</button>
</div>
</form>
</div>
</div>
<div class="col-lg-3"></div>
</div>
<div class="billing"> <br><br>
<div class="checkout_title">Orders</div><br/>
<div class="row">
<?php
$sql = "SELECT COUNT(id) FROM my_orders WHERE user_id='$user_id' ORDER BY id DESC";
$query = mysqli_query($con, $sql);
$row = mysqli_fetch_row($query);
//here we have the total row count
$rows = $row[0];
//number of results we want per page
$page_rows = 50;
//tells us the page number of our last page
$last = ceil($rows/$page_rows);
//this makes sure last cannot be less than 1
if($last < 1){$last = 1;}
//establish the page num variable
$pagenum = 1;
//Get pageum from $GET if it is present, else its 1
if(isset($_GET['pn'])){
$pagenum = preg_replace('#[^0-9]#', '', $_GET['pn']);
}
//below 1 or more than last page
if($pagenum < 1){
$pagenum = 1;
}else if ($pagenum > $last) {
$pagenum = $last;
}
//this sets the range of rows to query for the chosen pagenum
$limit = 'LIMIT ' .($pagenum - 1) * $page_rows .',' .$page_rows;
//grabs one page worth of rows
$sql = "SELECT * FROM my_orders WHERE user_id='$user_id' ORDER BY id DESC $limit ";
$query = mysqli_query($con, $sql);
//this shows the user what page they on and total number
$textline1 = "Messages $rows";
$textline2 = "Page $pagenum of $last";
//establish the pagination controls
$paginationCtrls = "";
//if there is more than one page worth of results
if($last != 1){
if($pagenum > 1){
$previous = $pagenum - 1;
//$paginationCtrls .='<a href="'.$_SERVER['PHP_SELF'].'?pn='.$previous.'">Previous</a>  ';
$paginationCtrls .='<li><a href="'.$_SERVER['PHP_SELF'].'?pn='.$previous.'">Prev</a></li>';
//render clickable links to the left of target page number
for($i = $pagenum-4; $i < $pagenum; $i++){
if($i > 0){
//$paginationCtrls .= '<a href="'.$_SERVER['PHP_SELF'].'?pn='.$i.'"></a> ';
$paginationCtrls .= '<li><a href="'.$_SERVER['PHP_SELF'].'?pn='.$i.'">'.$i.'</a></li>';
}
}
}
//render target number bt not link
//$paginationCtrls .= ''.$pagenum.' ';
$paginationCtrls .= '<span class="pagination"><ul><li class="active"><a href="#">'.$pagenum.'</a></li></ul></span>';
//render clickable number links to the right of target number
for($i = $pagenum+1; $i <= $last; $i++){
//$paginationCtrls .= '<a href="'.$_SERVER['PHP_SELF'].'?pn='.$i.'">'.$i.'</a> ';
$paginationCtrls .= '<li><a href="'.$_SERVER['PHP_SELF'].'?pn='.$i.'">'.$i.'</a></li>';
if($i >= $pagenum+4){
break;
}
}
//this does the same as above, only checking if we are on the last page
if($pagenum != $last) {
$next = $pagenum + 1;
$paginationCtrls .= '<li><a href="'.$_SERVER['PHP_SELF'].'?pn='.$next.'">Next</a></li>';
}
}
if(mysqli_num_rows($query) > 0 ){$countt=0;
while ($row_ads = mysqli_fetch_array($query, MYSQLI_ASSOC)) {
$id = $row_ads['id'];
$order_id = $row_ads['order_id'];
echo"
<div class='col-lg-2'>
<a href='order_details.php?order_id=$order_id' style='font-size:16px;text-decoration:underline;'>$order_id</a>
</div>
";?>
<?php
}//end of while
}
else{echo"No orders are available at this time.";}
?>
</div>
</div>
<div class="col-12 text-center"><br/><br/>
<ul class="pagination clearfix">
<?php
echo"$paginationCtrls<br/><br/><br/><br/>";
echo "<div class='text_line'>$textline2</div>";
?>
</ul>
</div>
</div>
</div>
<?php include("footer.php"); ?>