forked from Bibhushan17/Vetinary-Shop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsett.php
More file actions
183 lines (153 loc) · 6.11 KB
/
Copy pathsett.php
File metadata and controls
183 lines (153 loc) · 6.11 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<!DOCTYPE html>
<?php
session_start();
if(!isset($_SESSION['loggedin'])|| $_SESSION['loggedin']!==true)
{
header("Location:login.php");
exit();
}
include('nav.php');
include('db.php');
$username = $_SESSION['username'];
// var_dump($username);
$query = "SELECT * FROM users WHERE username='$username'";
$result = mysqli_query($conn, $query);
// if (mysqli_num_rows($result) === 0) {
// die("No user found with the username: $username");
// }
if (!$result) {
die("Database query failed: " . mysqli_error($conn));
}
$userData = mysqli_fetch_assoc($result);
// $query = mysqli_query($conn, "SELECT * FROM users WHERE username='$username'");
// $userData = mysqli_fetch_assoc($query);
// var_dump($userData);
// Check if the form is submitted for updating user info or profile picture
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Handle image upload for profile picture if needed
if(isset($_POST['update']))
{
if ($_FILES['profile_image']['name']) {
$profileImage = $_FILES['profile_image']['name'];
$targetDirectory = "profile_images/";
$targetFile = $targetDirectory . basename($profileImage);
move_uploaded_file($_FILES['profile_image']['tmp_name'], $targetFile);
// Update the profile image filename in the database
mysqli_query($conn, "UPDATE users SET profile_image='$profileImage' WHERE username='$username'");
// Update the user data in the session
$_SESSION['profile_image'] = $profileImage;
// Reload the page to reflect the updated image
header("Location: settings.php");
exit();
}
}
if(isset($_POST['sendemail'])){
echo "Send button chai thichiyo hai ";
}
// Handle other user information updates if needed
// Example: $fullname = $_POST['fullname'];, $email = $_POST['email'];, etc.
}
?>
<html lang="en">
<head>
<title>Laundry Management System - Profile Settings</title>
<meta charset="UTF-8" />
<style>
/* Your CSS styles here */
.change{
width:30px;
}
.container
{
width: 50%;
text-align: center;
align-items: center;
justify-content: center;
margin-left: 20%;
margin-top: 5%;
}
.block
{
width: 50%;
text-align: center;
align-items: center;
justify-content: center;
margin-left: 20%;
margin-top: 7%;
padding: 5px 5px;
white-space: no wrap;
}
.block label
{
font-size: 2em;
margin-top:10px;
margin-bottom: 5px;
}
</style>
</head>
<body>
<div class="block">
<h1>User Profile Settings</h1>
<div class="profile-info">
<form method="POST" enctype="multipart/form-data">
<label>Fullname:</label>
<p style="color: black; font-size: 1.5em;"><?php echo $userData['fullname']; ?></p>
<label>Username:</label>
<p style="color: black;font-size: 1.5em;"><?php echo $userData['username']; ?></p>
<label>Email:</label>
<p style="color: black; font-size: 1.5em;"><?php echo $userData['email']; ?></p>
<label>Address:</label>
<p style="color: black; font-size: 1.5em;"><?php echo $userData['address']; ?></p>
<label>Phone Number:</label>
<p style="color: black; font-size: 1.5em;"><?php echo $userData['phone']; ?></p>
</form>
</div>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
Change Password: <input type="Password" name="updatepassword" required>
<input type="Submit" name="submitupdate" value="update">
</form>
</div>
<div class="container">
<div>
<form class="formX" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<h2>Contact Us</h2><br>
<label for="email">Email:</label><br>
<input type="email" id="email" name="email" placeholder="Enter your email address." required><br>
<label for="feedback">Feedback:</label><br>
<textarea id="feedback" name="feedback" placeholder="Enter your feedback or any queries." required></textarea>
<button type="submit" name="sendemail">Send</button><br><br>
<p>Call us at: +977-9842245984</p>
</form>
</div>
<?php
if(isset($_POST['submitupdate'])){
$newpass=$_POST['updatepassword'];
$sssqqqlll="UPDATE `users` SET `password` ='$newpass' WHERE username = '$username';";
if (mysqli_query($conn, $sssqqqlll)) {
echo '<script>alert("Your password has been changed")</script>';
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
}
// Check if the user is logged in (implement your login system here)
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['email']) && isset($_POST['feedback'])) {
// Sanitize user input to prevent SQL injection (always sanitize user input)
$email = mysqli_real_escape_string($conn, $_POST['email']);
$feedback = mysqli_real_escape_string($conn, $_POST['feedback']);
// Insert the feedback into the database
$sql = "INSERT INTO feedback (email, feedback) VALUES ('$email', '$feedback')";
if (mysqli_query($conn, $sql)) {
echo "Feedback submitted successfully!";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
} else {
if ($_SERVER["REQUEST_METHOD"] == "POST") {
echo "Please fill out the feedback form.";
}
}
// Close the database connection
mysqli_close($conn);
?>
</body>
</html>