Skip to content

Commit db5f5a4

Browse files
Refactor customer profile query to use prepared
statement
1 parent 445668f commit db5f5a4

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

profile-customer.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@
1515
$stmt->execute();
1616
$results = $stmt->fetchAll();
1717

18-
$customer_fullname = $results[0]['fullname'];
18+
$sql = 'SELECT fullname
19+
FROM customers
20+
WHERE id = :id';
21+
$stmt = $db->prepare($sql);
22+
$stmt->bindParam(':id', $customer_id);
23+
$stmt->execute();
24+
$info = $stmt->fetch();
25+
$customer_fullname = $info['fullname'];
1926

2027
?>
2128

0 commit comments

Comments
 (0)