nashsaint Posted May 9, 2008 Share Posted May 9, 2008 Hi, I wanted to add a simple shoutbox to my site. I searched the internet and i found loads of script but i don't know how to manipulate them to satisfy what i want. All I want is a very simple script that would integrate to my existing sql. Would be great is you could direct me where to look, or share your own script. Thanks. Link to comment https://forums.phpfreaks.com/topic/104811-shoutbox/ Share on other sites More sharing options...
conker87 Posted May 9, 2008 Share Posted May 9, 2008 A shoutbox is one of the easiest (IMHO) scripts to make. If you don't want anything gimmicky, then the following may help. <?php if ($_POST['shoutSubmit'] { $name = mysql_real_escape_string($_POST['name']); $shout = mysql_real_escape_string($_POST['shout']); $date = time(); $query = "INSERT INTO `shoutbox` VALUES(NULL, '$name', '$date', '$shout')"; // table: 'id' (int auto_incre), 'name' (varchar(64)), 'date' (timestamp), 'shout' (varchar(200)) $result = mysql_query($query) or die(mysql_error()); $message = "Your shout has been added."; } $query = "SELECT * FROM `shoutbox` ORDER BY `id` LIMIT 0,10"; // show only the 10 latests 'shouts' $result = mysql_query($query); while ($row = mysql_fetch_array($result)) { $date = date("F j, Y, g:i a", $row['date']); // Convert timestamp to 'May 9, 2008, 8:20 pm' format. echo "$row[name] ($date) shouted:<br />$row[shout]<br /><br />"; // Format this how you like, row names are pretty self explanatory. } ?><br /> <?php echo $message; ?> <form action="shoutbox.php" method="POST"> <input type="text" name="name" maxlength="64" /><br /> <textbox name="shout"></textbox><br /> <input type="submit" name="shoutSubmit" /> </form> I've just knocked this up, so something like that. I can't test it, since I'm at work. Link to comment https://forums.phpfreaks.com/topic/104811-shoutbox/#findComment-536530 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.