-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedit_profile.php
More file actions
143 lines (134 loc) · 6.95 KB
/
edit_profile.php
File metadata and controls
143 lines (134 loc) · 6.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?php session_start() ?>
<!DOCTYPE HTML>
<html lang="en-CA">
<head>
<title>La Hacienda - From Farm to Fork</title>
<meta name="description" content="La Hacienda delivers farm fresh organic food straight from the producer and onto your fork. All meat and produce sold is sustainably grown with utmost respect for animals and care for the future of our planet. La Hacienda is your local farmers market hooked up to the digital world, bringing your the freshest to your fingertips.">
<meta name="keywords" content="organic food, sustainable, farm fresh, fresh">
<meta name="author" content="Jan Mikhail Alexei Ong (SID: 40154849)">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="UTF-8">
<!-- BOOTSTRAP LIBRARIES -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.7/css/all.css">
<script src="https://kit.fontawesome.com/6ebd7b3ed7.js" crossorigin="anonymous"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<!---->
<!--GOOGLE FONT APIS-->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Bodoni+Moda">
<!---->
<!--EXTERNAL STYLESHEET & JS-->
<link rel="stylesheet" href="lahacienda.css">
<script src="lahacienda.js"></script>
<!---->
</head>
<body>
<!--START PAGE HEADER-->
<div class="topnav" id="myTopnav">
<a href="/index.php"><img src="assets/logo-white.png" style="width:150px; float:left" class="m-1 mx-2 p-1"></a>
<a href="#" class="element" style="float:left">
<?php if(isset($_SESSION['session_username'])) { ?>
<?php echo "Welcome " . $_SESSION['session_username']; ?>
<?php } ?>
</a>
<a href="javascript:void(0);" class="icon element" onclick="myFunction()"><i class="fa fa-bars"></i></a>
<a href="/index.php" class="active element">Return to Storefront</a>
<a href="/orders.php" class="element">Orders</a>
<a href="/customers.php" class="element">Customers</a>
<a href="/add_prod.php" class="element">Add Product</a>
<a href="/inventory.php" class="element">Inventory</a>
</div>
<script>
function myFunction() {
var x = document.getElementById("myTopnav");
if (x.className === "topnav") {
x.className += " responsive";
} else {
x.className = "topnav";
}
}
</script>
<!--END PAGE HEADER-->
<!--LOAD PROFILE-->
<?php
//load contents of database
$string_data = file_get_contents("users.php");
//unserialize contents
$users = unserialize($string_data);
//isolate associative array from POST
foreach ($_POST as $key => $val) {
$array = $val;
}
//isolate key
foreach ($array as $key => $val) {
$name = $key;
}
//search key within database (i.e. name)
$key = array_search($key, array_column($users, 'username'));
?>
<!---->
<!--CONTENT-->
<div class="content-container">
<h1>EDIT PROFILE</h1>
<br />
<hr>
<form action="editProfileFunc.php" method="POST">
<label for="email">Email</label>
<input type="text" placeholder="Enter Email" name="email" id="email" pattern="^\S+@\S+$" value="<?php echo $users[$key]['email']; ?>" required>
<label for="username">Username</label>
<input type="text" placeholder="Enter Username" name="username" id="username" value="<?php echo $users[$key]['username']; ?>" required>
<label for="psw">Password (minimum 8 characters, at least one letter and one number)</label>
<input type="password" placeholder="Enter Password"
name="psw" id="psw" pattern="^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$" disabled>
<hr>
<label for="name">Full Name</label>
<input type="text" placeholder="Enter Full Name" name="name" id="name" value="<?php echo $users[$key]['fullname']; ?>" required>
<label for="street">Street Address</label>
<input type="text" placeholder="Enter Street Address" name="address" id="address" value="<?php echo $users[$key]['street']; ?>" required>
<label for="city">City</label>
<input type="text" placeholder="Enter City" name="city" id="city" value="<?php echo $users[$key]['city']; ?>" required>
<label for="state">State</label>
<input type="text" placeholder="Enter State" name="state" id="state" value="<?php echo $users[$key]['state']; ?>" required>
<label for="postal">Postal Code (i.e. A1A 1A1)</label>
<input type="text" placeholder="Enter Postal Code" name="postal" id="postal"
pattern="^[A-Za-z]\d[A-Za-z][ -]?\d[A-Za-z]\d$" value="<?php echo $users[$key]['postalcode']; ?>" required>
<label for="phone">Phone Number (i.e. 123-456-7890)</label>
<input type="text" placeholder="Enter Phone Number" name="phone" id="phone"
pattern="^(\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4}$" value="<?php echo $users[$key]['phone']; ?>" required>
<hr>
<input type="submit" value="Submit" name="user[<?php echo $user['username']; ?>]">
</form>
</div>
<!--END CONTENT-->
<!--FOOTER-->
<footer class="blog-footer pt-3">
<div class="row">
<div class="col-sm-4 text-center">
<a href="about.php">About Us</a>
<a href="contact.php">Contact Us</a>
<a href="shipping.html">Shipping & Returns</a>
<a href="privacy.html">Privacy Policy</a>
</div>
<div class="col-sm-4 text-center">
<a href="careers.html">Join Our Team</a>
<a href="supplier.html">Become a Supplier</a>
<a href="recipes.html">Recipes</a>
<a href="employee.php">Employee Login</a>
</div>
<div class="col-sm-4 text-center">
<form action="#">
<label for="email" style="color: #f2f2f2;">Subscribe to us for exclusive offers!</label><br/>
<input type="text" id="email" name="email" style="width:50%;" placeholder="Your e-mail address...">
</div>
</div>
</footer>
<!--BOTTOM BAR-->
<footer class="container-fluid text-center pt-3">
<p style="font-family: 'Bodoni Moda'; color: #f2f2f2; font-size:small;">© La Hacienda - Farm to Fork | All Rights Reserved.</p>
</footer>
<!--END FOOTER-->
</body>
</html>