Guest User

Home.php

a guest
Jun 20th, 2013
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.83 KB | None | 0 0
  1. ?php
  2.  
  3. //includes
  4.  
  5. include('connect.php');
  6.  
  7. //get cookie value & display username if cookie set.
  8.  
  9. If(isset($_COOKIE['username'])) {
  10. echo "Welcome" . $_COOKIE['user'] . "!<br />";
  11.  
  12. //retrieve user ID for accessing user profile.
  13.  
  14. $username = $_COOKIE['username'];
  15.  
  16. //search for user with username stored in cookie in database, then obtain their profile ID.
  17.  
  18. $sql = "SELECT user_id FROM users WHERE username='$username'";
  19. $id = mysql_query($sql);
  20.  
  21.  
  22. } else {
  23.  
  24. echo "Welcome, Guest! <br/>";
  25.  
  26. }
  27.  
  28. ?>
  29.  
  30. <html>
  31. <head>
  32. <center><b>
  33. Home
  34. </b></center>
  35. <style type="text/css">
  36. a:link {color:blue;text-decoration:none;}
  37. a:visited {color:purple;text-decoration:none;}
  38. a:hover {color:black;text-decoration:none;}
  39. </style>
  40. </head>
  41.  
  42. <title> Home </title>
  43. <br />
  44. <hr />
  45. <br />
  46. <br />
  47. <? php 'a href=profile.php?id=."$id".' ?>
Advertisement
Add Comment
Please, Sign In to add comment