Advertisement
Guest User

profile.php

a guest
Jan 28th, 2015
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. <html><body background="background4.png"><center>
  2. <?php
  3. session_start();
  4.  
  5. if(!isset($_SESSION['user_id']))
  6. {
  7. $message = 'You must be logged in to access this page';
  8. header("location:index.php");
  9. }
  10. else
  11. {
  12. try
  13. {
  14. $user_id = $_SESSION['user_id'];
  15. $mysql_hostname = 'localhost';
  16. $mysql_username = 'root';
  17. $mysql_password = 'mydatabase-password';
  18. $mysql_dbname = 'my-db';
  19. $dbh = new PDO("mysql:host=$mysql_hostname;dbname=$mysql_dbname", $mysql_username, $mysql_password);
  20. $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  21.  
  22. $stmt = $dbh->prepare("SELECT * FROM users WHERE user_id = :user_id");
  23. $stmt->bindParam(':user_id', $_SESSION['user_id'], PDO::PARAM_INT);
  24. $stmt->execute();
  25. $row = $stmt->fetch(PDO::FETCH_ASSOC);
  26. }
  27. catch (Exception $e)
  28. {
  29. $message = 'We are unable to process your request. Please try again later"';
  30. }
  31. }
  32. ?>
  33. <table width="398" border="0" align="center" cellpadding="0">
  34. <tr>
  35. <td height="26" colspan="2">Testing Data Information </td>
  36. <td><div align="right"><a href="profile.php">Update Data</a></div></td>
  37. </tr>
  38. <tr>
  39. <td width="129" rowspan="5"><img src="<?php echo $row['picture']; ?>" width="129" height="129" alt="no image found"/></td>
  40. <td width="82" valign="top"><div align="left">User ID:</div></td>
  41. <td width="165" valign="top"><?php echo $row['user_id']; ?></td>
  42. </tr>
  43. <tr>
  44. <td valign="top"><div align="left">User Name:</div></td>
  45. <td valign="top"><?php echo $row['username']; ?></td>
  46. </tr>
  47. <tr>
  48. <td valign="top"><div align="left">E-mail:</div></td>
  49. <td valign="top"><?php echo $row['email']; ?></td>
  50. </tr>
  51. <tr>
  52. <td valign="top"><div align="left">Address: </div></td>
  53. <td valign="top"><?php echo $row['address']; ?></td>
  54. </tr>
  55. <tr>
  56. <td valign="top"><div align="left">Phone Number: </div></td>
  57. <td valign="top"><?php echo $row['phone']; ?></td>
  58. </tr>
  59. </table>
  60. <p align="center"><a href="profile.php"></a></p>
  61. </html></body></center>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement