Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Yahoo Ansers' Question: http://answers.yahoo.com/question/answer?qid=20130620074829AAJvlEe
- // Variable to hold the message we want displayed.
- $message = '';
- // Check and see if the $_COOKIE['username'] exists
- If(isset($_COOKIE['username'])) {
- require_once('connect.php');
- $username = mysql_real_escape_string( $_COOKIE['username'] );
- $sql = "SELECT user_id FROM users WHERE username='{$username}' LIMIT 1";
- $result = mysql_query($sql);
- // Check to make sure statement and query are good.
- if( !$result ){
- $message .= 'Internal Error: ' . mysql_error();
- }else if( mysql_num_rows($result) === 0){
- $message .= 'Welcome, Guest!<br />';
- }else{
- $row = mysql_fetch_assoc($result);
- $user_id = $row['user_id'];
- $message .= 'Welcome . ' . $username . '!<br /><br />';
- $message .= 'Your <a href="profile.php?id=' . $user_id . '">Profile Page</a> awaits.';
- }
- } else {
- $message .= "Welcome, Guest! <br/>";
- }
- ?>
- <html>
- <head>
- <title>Home</title>
- <style type="text/css">
- a:link {
- color: blue;
- text-decoration: none;
- }
- a:visited {
- color: purple;
- text-decoration: none;}
- a:hover {
- color: black;
- text-decoration: none;
- }
- h3 {
- text-align: center;
- }
- </style>
- </head>
- <body>
- <h3>Home</h3>
- <hr />
- <br />
- <br />
- <?php echo $message; ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement