01.
$HOST_NAME
=
"127.0.0.1"
;
02.
$DB_NAME
=
"furniture"
;
03.
$CHAR_SET
=
"charset=utf8"
;
04.
$USERNAME
=
"root"
;
05.
$PASSWORD
=
""
;
06.
07.
try {
08.
09.
$db
=
new
PDO(
'mysql:host='
.
$HOST_NAME
.
';dbname='
.
$DB_NAME
.
';'
.
$CHAR_SET
,
$USERNAME
,
$PASSWORD
);
10.
11.
12.
13.
14.
$sql
= "UPDATE customers SET
15.
username = :username,
16.
password = :password,
17.
surname = :surname,
18.
lastname = :lastname,
19.
address = : address,
20.
phone = :phone,
21.
email = :email,
22.
line_id = :line_id
23.
WHERE id = :id";
24.
25.
$statement
=
$db
->prepare(
$sql
);
26.
$statement
->bindParam(
":username"
,
$_POST
[
'username'
], PDO::PARAM_STR);
27.
$statement
->bindParam(
":password"
,
$_POST
[
'password'
], PDO::PARAM_STR);
28.
$statement
->bindParam(
":surname"
,
$_POST
[
'surname'
], PDO::PARAM_STR);
29.
$statement
->bindParam(
":lastname"
,
$_POST
[
'lastname'
], PDO::PARAM_STR);
30.
$statement
->bindParam(
":address"
,
$_POST
[
'address'
], PDO::PARAM_STR);
31.
$statement
->bindParam(
":phone"
,
$_POST
[
'phone'
], PDO::PARAM_STR);
32.
$statement
->bindParam(
":email"
,
$_POST
[
'email'
], PDO::PARAM_STR);
33.
$statement
->bindParam(
":line_id"
,
$_POST
[
'line_id'
], PDO::PARAM_STR);
34.
$statement
->bindParam(
':id'
,
$_POST
[
'id'
], PDO::PARAM_INT);
35.
36.
37.
header(
'Location: admin_customer.php'
);
38.
39.
40.
} catch (PDOException
$e
) {
41.
42.
echo
"ไม่สามารถเชื่อมต่อฐานข้อมูลได้ : "
.
$e
->getMessage();
43.
44.
}
45.
?>