Shoutbox

By supafreky on Mar 09, 2008

You have to name tables feilds as they are in the script, or rename them. If you don't understand mysql then you shouldn't use this script as it might be hard setting up mysql to work with this script. You have to manually add members inorder for them to login. This is my 7th php script :D

<?php
  $dbuser = "dbuser";
  $dbpass = "dbpass";
  $dbname = "dbname";
  $table = "table1";
  $table2 = "table2";

  if ($_POST['user'] && $_POST['pass'] && !$_COOKIE['login']) 
  {
    $user = md5($_POST['user']);
    $pass = md5($_POST['pass']);
    $sql = mysql_connect('localhost', $dbuser, $dbpass) or exit(mysql_error());

    mysql_select_db($dbname, $sql) or exit(mysql_error());

    $query = mysql_query("SELECT * FROM $table WHERE (`username`, `password`) = ('" . $user . "', '" . $pass . "')") or exit(mysql_error());
    $info = mysql_fetch_array($query);
    if ($info) 
    {
      setcookie("login", $_POST["user"], time()+3600);
    }
  }
  else if ($_COOKIE['login']) 
  {
    $user = $_COOKIE['login'];
    print("<center>You are logged in as " . $user . "</center>");
    $sql = mysql_connect('localhost', $dbuser, $dbpass) or exit(mysql_error());
    mysql_select_db($dbname, $sql) or exit(mysql_error());
    if ($_POST['msg']) 
    {
      $msg = $_POST['msg'];
      $time = date("[H:i:s]");
      mysql_query("INSERT INTO " . $table2 . " (`time`, `user`, `msg`) VALUES ('" . $time . "', '" . $user . "', '" . $msg . "')") or exit(mysql_error());
    }
    $info = mysql_query("SELECT * FROM " . $table2) or exit(mysql_error());
    while ($read = mysql_fetch_array($info)) 
    {
      $msg = $msg . "\r\n" . $read[0] . " <" . $read[1] . "> " . $read[2];
    }
  }
?>
<html>
  <head>
    <title>KINGSKROWN ILLUMINATI</title>
  </head>
  <body>
    <center>
      <form action="<?=$_SERVER['PHP_SELF'];?>" method="post">
        <p>Username:</p>
        <input name="user" type="text" maxlength="12" value="" />      
        <p>Password:</p>
        <input name="pass" type="password" maxlength="30" value="" />
        <input name="login" type="submit" value="Login" />
        <textarea name="box" rows="10" cols="75" readonly="readonly"><?=$msg;?></textarea>
        <br />
        <input type="text" name="msg" maxlength="50" value="" />
        <input type="submit" value="Shout" />
        <br />
        </form>
    </center>
  </body>
</html>

Comments

Sign in to comment.
Joshuaxiong1   -  Mar 08, 2009

I can't post anything. What sup with the password UP?

 Respond  
F*U*R*B*Y*   -  Mar 10, 2008

post the SQL for the table......

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.