Advertisement
MorganF

Simple user page

Mar 28th, 2015
1,576
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.47 KB | None | 0 0
  1. <?php
  2.    
  3.     $requested_user = $_GET['id'];
  4.    
  5.     $db = new PDO('mysql:host=localhost;dbname=testdb;charset=utf8', 'root', 'MyPassword');
  6.    
  7.     try {
  8.        
  9.         $stmt = $db->prepare("SELECT * FROM c_userpage WHERE id = ?");
  10.        
  11.         $stmt->execute(array($requested_user));
  12.        
  13.         $mydata = $stmt->fetch();
  14.        
  15.     } catch (Exception $e) {
  16.        
  17.         //error with mysql
  18.         die();
  19.        
  20.     }
  21.    
  22.     echo "Hello! my name is {$mydata['username']}!\n";
  23.     echo "About Me: {$mydata['custom_data']}";
  24.    
  25. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement