Skip to content

Commit 500d2c5

Browse files
committed
Don't teach people bad practices
1 parent 58d6a62 commit 500d2c5

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,11 @@ Next, create the following in presence_auth.php:
137137
```php
138138
<?php
139139
header('Content-Type: application/json');
140-
if ($_SESSION['user_id']){
141-
$sql = "SELECT * FROM `users` WHERE id='$_SESSION[user_id]'";
142-
$result = mysql_query($sql,$mysql);
143-
$user = mysql_fetch_assoc($result);
140+
if (isset($_SESSION['user_id'])) {
141+
$stmt = $pdo->prepare("SELECT * FROM `users` WHERE id = :id");
142+
$stmt->bindValue(':id', $_SESSION['user_id'], \PDO::PARAM_INT);
143+
$stmt->execute();
144+
$user = $stmt->fetch();
144145
} else {
145146
die('aaargh, no-one is logged in')
146147
}

0 commit comments

Comments
 (0)