Jump to content

  • Free consultations and support
  • Live chatClick Here for Live Chat
  • Call ico 1888-906-1888
    Phone support: Open

    Ready for your call :)

    Our business hours:

    Mon — Fri, 2am — 8pm (EST)

    US & EU support teams

    Phone support: Closed

    We are back in: 1h 20m

    Our business hours:

    Mon — Fri, 2am — 8pm (EST)

    US & EU support teams


Php Shoutbox Script I Made


  • Please log in to reply
&nsbp;

#1 danieljmccoy

danieljmccoy

    Apprentice Designer

  • Designer
  • 93 posts

Posted 20 July 2003 - 05:45 PM

Hi everyone, I just finished making a little shoutbox script and I thought that I would share it with everyone. You can see a demo HERE Enjoy.

MySQL query:

CREATE TABLE shoutbox (
id int(11) NOT NULL auto_increment,
name text NOT NULL,
message longtext NOT NULL,
time text NOT NULL,
ip text NOT NULL,
PRIMARY KEY (id)
) TYPE=MyISAM;

Code (remember to change config variables -> line 36):

<style type="text/css">
<!--
.shouttableborder {
	border: 1px dashed #A8A8A8;
	padding: 2px;
}
.namepostedbg {
	background-color: #99AEAE;
	font-family: Arial, Tahoma;
	font-size: 10px;
	color: #FFFFFF;
	font-weight: normal;
	text-indent: 2pt;
	border-bottom-width: 1px;
	border-bottom-style: none;
	border-bottom-color: #FFFFFF;
}
.messagestyle {
	font-family: Arial, Tahoma;
	font-size: 10px;
	color: #99AEAE;
	background-color: #F5F5F5;
	text-indent: 2pt;
}
SELECT, option, textarea, input {  
	font-family: Arial, Tahoma; 
	font-size: 10px; color: #000000; 
	background-color: #fefefe; 
	border: 1px #000000 solid;
}
-->
</style>
<table width="175" border="0" cellpadding="0" cellspacing="0" class="shouttableborder">
  <tr> 
    <?
//--- BEGIN CONFIGURATION SECTION
$host          ="localhost";
$username      ="yourmysqlusername";
$userpass      ="yourmysqlpass";
$userdatabase  ="yourmysqldatabase";
//--- END CONFIGURATION SECTION
mysql_pconnect("$host","$username","$userpass");
mysql_select_db("$userdatabase");
if($submit)
{
	$ipget = mysql_query("SELECT * FROM shoutbox ORDER BY id DESC LIMIT 1");
    while($r=mysql_fetch_array($ipget))
	{
	$lastip = $r["ip"];
	}
	$name = strip_tags($_POST['name'], '');
	$message = strip_tags($_POST['message'], '');
	if($name=="name")
	{$name = "Guest";}
    $time=date("M d, y");
	$ip =$REMOTE_ADDR;
	if($ip==$lastip)
	{}else{
	$result=MYSQL_QUERY("INSERT INTO shoutbox (id,name,message,time,ip)"."VALUES ('NULL','$name', '$message','$time','$ip')");
	}
}
	$result = mysql_query("SELECT * FROM shoutbox ORDER BY id DESC LIMIT 6");
    while($r=mysql_fetch_array($result))
    {        
    $time=$r["time"]; 
    $id=$r["id"];
    $message=$r["message"];
    $name=$r["name"];
	$ip=$r["ip"];
?>
    <td class="namepostedbg"><? echo $time ?> - <? echo $name ?></td>
  </tr>
  <tr> 
    <td class="messagestyle"><p><? echo $message ?></p></td>
  </tr>
  <? } ?>
  <td class="namepostedbg">Add Shout</td>
  </tr><tr><td class="messagestyle">
  <form action="<? echo $php_self ?>" method="post">
    <INPUT TYPE='TEXT' value='name' NAME='name' SIZE=15 maxlength='100'>
    <input type='TEXT' value='message' name='message' size=15 maxlength='100'></td></tr>
    <tr> 
      <td class="messagestyle"> <input type="submit" name="submit" value="shout"> 
  </form></td></tr>
</table>

If you save the code above in a file named shoutbox.php to put it on your page, all you have to do is put the below code where you want it to be:

<? include('shoutbox.php'); ?>


#2 karl472001

karl472001

    Apprentice Designer

  • Designer
  • 352 posts

Posted 20 July 2003 - 07:25 PM

.

#3 danieljmccoy

danieljmccoy

    Apprentice Designer

  • Designer
  • 93 posts

Posted 20 July 2003 - 10:19 PM

To execute the query, use PhpMyAdmin. There is a tutorial here.

#4 karl472001

karl472001

    Apprentice Designer

  • Designer
  • 352 posts

Posted 20 July 2003 - 10:22 PM

.

#5 Guest_Fred2D_*

Guest_Fred2D_*
  • Guests

Posted 20 July 2003 - 10:23 PM

Great!
I'm sure that's great coding. I dont know anything about php nor coding.
That's one pretty messed up site.

I'd like to see a demo of the scripts in use!

#6 danieljmccoy

danieljmccoy

    Apprentice Designer

  • Designer
  • 93 posts

Posted 20 July 2003 - 10:25 PM

There is a link to the demo at the top of the post :D .

#7 Guest_Fred2D_*

Guest_Fred2D_*
  • Guests

Posted 20 July 2003 - 10:30 PM

That shoutbox is great!
I think I'll use it somewhere.
Is it 100% free?

#8 danieljmccoy

danieljmccoy

    Apprentice Designer

  • Designer
  • 93 posts

Posted 20 July 2003 - 10:31 PM

Thanks, glad I could help out. B)

#9 Guest_Fred2D_*

Guest_Fred2D_*
  • Guests

Posted 20 July 2003 - 10:34 PM

Do you code News Scripts also?

#10 danieljmccoy

danieljmccoy

    Apprentice Designer

  • Designer
  • 93 posts

Posted 20 July 2003 - 10:36 PM

Yup, http://bit5.clanfxp.net it's my baby.

#11 Guest_Fred2D_*

Guest_Fred2D_*
  • Guests

Posted 20 July 2003 - 10:36 PM

You charge?

#12 danieljmccoy

danieljmccoy

    Apprentice Designer

  • Designer
  • 93 posts

Posted 20 July 2003 - 10:37 PM

No, I just like to make stuff.

#13 Guest_Fred2D_*

Guest_Fred2D_*
  • Guests

Posted 20 July 2003 - 10:41 PM

Originally posted by danieljmccoy@Jul 20 2003, 10:37 PM
No, I just like to make stuff.

Oh, so if I might have a site that needs a News Script in it.
Would you help me then?

#14 danieljmccoy

danieljmccoy

    Apprentice Designer

  • Designer
  • 93 posts

Posted 20 July 2003 - 10:41 PM

Sure, what do you need?

#15 Guest_Fred2D_*

Guest_Fred2D_*
  • Guests

Posted 21 July 2003 - 12:30 AM

Originally posted by danieljmccoy@Jul 20 2003, 10:41 PM
Sure, what do you need?

Nothing. :lol:
It was just a question.

#16 danieljmccoy

danieljmccoy

    Apprentice Designer

  • Designer
  • 93 posts

Posted 21 July 2003 - 12:33 AM

Oh, no problem.

#17 karl472001

karl472001

    Apprentice Designer

  • Designer
  • 352 posts

Posted 21 July 2003 - 02:32 AM

.

#18 karl472001

karl472001

    Apprentice Designer

  • Designer
  • 352 posts

Posted 21 July 2003 - 03:01 PM

VERY NICE. And very easy to set up. Only one thing, I make one shout, and then I try to shout again but I can't? Do I have to wait for someone else to shout? Do I have to use a different name?

#19 Guest_Fred2D_*

Guest_Fred2D_*
  • Guests

Posted 21 July 2003 - 04:28 PM

Originally posted by karl472001@Jul 21 2003, 03:01 PM
VERY NICE. And very easy to set up. Only one thing, I make one shout, and then I try to shout again but I can't? Do I have to wait for someone else to shout? Do I have to use a different name?

I got the same problem. <_<

#20 danieljmccoy

danieljmccoy

    Apprentice Designer

  • Designer
  • 93 posts

Posted 22 July 2003 - 05:16 PM

Lol, you have to change your ip address. It will not let you post until someone else does. Here is the code without anti spam. Remember to change the mysql info.

<style type="text/css">
<!--
.shouttableborder {
border: 1px dashed #A8A8A8;
padding: 2px;
}
.namepostedbg {
background-color: #99AEAE;
font-family: Arial, Tahoma;
font-size: 10px;
color: #FFFFFF;
font-weight: normal;
text-indent: 2pt;
border-bottom-width: 1px;
border-bottom-style: none;
border-bottom-color: #FFFFFF;
}
.messagestyle {
font-family: Arial, Tahoma;
font-size: 10px;
color: #99AEAE;
background-color: #F5F5F5;
text-indent: 2pt;
}
SELECT, option, textarea, input {  
font-family: Arial, Tahoma; 
font-size: 10px; color: #000000; 
background-color: #fefefe; 
border: 1px #000000 solid;
}
-->
</style>
<table width="175" border="0" cellpadding="0" cellspacing="0" class="shouttableborder">
 <tr> 
   <?
//--- BEGIN CONFIGURATION SECTION
$host          ="localhost";
$username      ="MySQLusername";
$userpass      ="MySQLpassword";
$userdatabase  ="MySQLdatabase";
//--- END CONFIGURATION SECTION
mysql_pconnect("$host","$username","$userpass");
mysql_select_db("$userdatabase");
if($submit)
{
$name = strip_tags($_POST['name'], '');
$message = strip_tags($_POST['message'], '');
if($name=="name")
{$name = "Guest";}
   $time=date("M d, y");
$ip =$REMOTE_ADDR;
$result=MYSQL_QUERY("INSERT INTO shoutbox (id,name,message,time,ip)"."VALUES ('NULL','$name', '$message','$time','$ip')");
}
$result = mysql_query("SELECT * FROM shoutbox ORDER BY id DESC LIMIT 6");
   while($r=mysql_fetch_array($result))
   {        
   $time=$r["time"]; 
   $id=$r["id"];
   $message=$r["message"];
   $name=$r["name"];
$ip=$r["ip"];
?>
   <td class="namepostedbg"><? echo $time ?> - <? echo $name ?></td>
 </tr>
 <tr> 
   <td class="messagestyle"><p><? echo $message ?></p></td>
 </tr>
 <? } ?>
 <td class="namepostedbg">Add Shout</td>
 </tr><tr><td class="messagestyle">
 <form action="<? echo $php_self ?>" method="post">
   <INPUT TYPE='TEXT' value='name' NAME='name' SIZE=15 maxlength='100'>
   <input type='TEXT' value='message' name='message' size=15 maxlength='100'></td></tr>
   <tr> 
     <td class="messagestyle"> <input type="submit" name="submit" value="shout"> 
 </form></td></tr>
</table>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users