Advertisement
Guest User

Untitled

a guest
Jan 13th, 2013
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.38 KB | None | 0 0
  1. <?php
  2.  
  3. date_default_timezone_set('Europe/London');
  4.  
  5. $site = "http://www.socialf.tk";
  6.  
  7. error_reporting(E_ALL ^ E_NOTICE);
  8. ?>
  9. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  10. <html xmlns="http://www.w3.org/1999/xhtml">
  11. <head>
  12. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  13. <link href='styles/main.css' rel="stylesheet" type="text/css"></link>
  14. <title><?php echo $title; ?></title>
  15. <style type="text/css">
  16. body
  17. {
  18. background-color:#b0c4de;
  19. }
  20.  
  21. #login{
  22.  
  23. }
  24.  
  25. #window{
  26.     width:320px;
  27.     height:290px;
  28.     background-color:#D8D8D8;
  29.     border:1px solid #333333;
  30.     overflow:scroll
  31. }
  32.  
  33. #send{
  34.     width:320px;
  35.     height:33px;
  36.     background-color:;
  37.     border:1px solid #333333;
  38. }
  39. #status{
  40.     width:320px;
  41.     height:25px;
  42.     background-color:;
  43. }
  44. </style>
  45. </head>
  46. <body>
  47.  
  48. <?php
  49. $title = "Social Fun";
  50. ?>
  51. <div id="wrapper">
  52. <?php
  53. session_start();
  54. $username = $_SESSION['username'];
  55. $userid = $_SESSION['id'];
  56. $user = $_SESSION['user'];
  57. if($user){
  58. require('connect.php');
  59. $time = date("d F, Y \a\\t\ H:i:s");
  60. ?>
  61.  
  62. <?php  
  63.    
  64.     echo "<div id='status'>";
  65.     echo "Your chatting username is: <b>$user</b>";
  66.     echo "<br>";
  67.     echo "</div>";
  68.     echo "<font color='red'>$errormsg</font>";
  69.  
  70.     echo "<div id='window'>";
  71.    
  72.         $query = mysql_query("SELECT * FROM chat ORDER BY time DESC");
  73.         $numrows = mysql_num_rows($query);
  74.         if($numrows >0 ){
  75.        
  76.             $query = "SELECT * FROM chat";
  77.  
  78.             $result = mysql_query($query);
  79.  
  80.             while ($row = mysql_fetch_array($result))
  81.             {
  82.                // display information for each dog.
  83.                echo "<b>$row[user]</b> On <i>$row[time]</i> - <br>$row[content]<hr>";
  84.             }
  85.            
  86.         }
  87.         else
  88.             echo "No message be the first!";
  89.             echo "<a name='chat'></a>";
  90.    
  91.     echo "</div>";
  92.        
  93.     $form = "<div id='send'>
  94.     <form action='chat.php#chat' method='post'>
  95.     <center><input type='text' name='msg' style='width:75%;' />
  96.     <input type='submit' name='loginbtn' id='loginbtn' /></center>
  97.     </div>";
  98.        
  99.         $message = $_POST['msg'];
  100.        
  101.         if($_POST['loginbtn']){
  102.        
  103.             if($message){
  104.                 echo "$form";
  105.                
  106.                 mysql_query("INSERT INTO chat VALUES('$user', '$time', '$message')");
  107.                
  108.             }
  109.             else
  110.                 echo "<font color='red'>You must enter a message.</font> $form";
  111.        
  112.         }
  113.         else
  114.             echo "$form";
  115.        
  116.        
  117.  
  118. ?> 
  119.    
  120.    
  121.    
  122.    
  123. <?php
  124. }
  125. else
  126.     echo "You must be logged in to chat.";
  127. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement