Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include('../config.php');
- $query = "
- SELECT
- id,
- pseudo
- FROM users
- ";
- try
- {
- // These two statements run the query against your database table.
- $stmt = $db->prepare($query);
- $stmt->execute();
- }
- catch(PDOException $ex)
- {
- // Note: On a production website, you should not output $ex->getMessage().
- // It may provide an attacker with helpful information about your code.
- die("Failed to run query: " . $ex->getMessage());
- }
- // Finally, we can retrieve all of the found rows into an array using fetchAll
- $info = $stmt->fetchAll();
- $id = $array[0]['id'];
- print_r($info);
- switch ($_REQUEST['action']) {
- case 'sendMessage':
- $query = $db->prepare("INSERT INTO messages SET id_user = ?, content=?");
- $query->execute([$id,$_REQUEST['message']]);
- break;
- }
- ?>
Add Comment
Please, Sign In to add comment