-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEditProfileSave.php
45 lines (37 loc) · 1.53 KB
/
EditProfileSave.php
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
<?php
session_start();
include ('server.php');
$errors = array();
if (isset($_POST['Edit_customers'])) {
// รับค่าจากฟอร์ม
$username = $_POST["username"];
$address = $_POST["address"];
$phone = $_POST["phone"];
$email = $_POST["email"];
$fname = $_POST["fname"];
$lname =$_POST["lname"];
$email =$_POST["email"];
// ตรวจสอบว่าผลิตภัณฑ์มีอยู่แล้วหรือไม่
$user_check_query = "SELECT * FROM customers WHERE username = '$username'";
$query = mysqli_query($conn, $user_check_query);
$result = mysqli_fetch_assoc($query);
if (count($errors) == 0) {
$sql = "UPDATE customers SET
username = '".$_POST["username"]."',
fname = '".$_POST["fname"]."',
lname = '".$_POST["lname"]."',
phone = '".$_POST["phone"]."',
address = '".$_POST["address"]."',
email = '".$_POST["email"]."'
WHERE username = '$username'";
$query = mysqli_query($conn, $sql);
header('location: profile.php');
}
}
// แสดงข้อผิดพลาดหากมี
if (!empty($errors)) {
$_SESSION['error'] = implode('<br>', $errors);
echo "<script> alert('เกิดข้อผิดพลาด!'); </script>";
echo "<script> window.location.href='profile.php?updated=true'; </script>";
}
?>