iGuest 3 Report post Posted November 26, 2004 Here's my tutorial of making a shoutbox.1. First of all we need to create the MySQL database (this is the important part): CREATE TABLE `shoutbox` ( `id` INT(12) NOT NULL AUTO_INCREMENT, `username` VARCHAR(25) NOT NULL, `email` VARCHAR(25) NOT NULL, `message` TEXT NOT NULL, `date` VARCHAR(15) NOT NULL, `ip` VARCHAR(25) NOT NULL , PRIMARY KEY (`id`)) All the details (the message, and stuff) are going to these tables.2. Now we will create the page called connect.php. With this page the shoutbox will connect to the database and send the message you wrote and all the other stuff.<?php $co_host = "localhost"; // sql database host $co_name = "username"; // username $co_pw = "password"; // password $co_db = "database name"; // database name you got access to mysql_connect($co_host,$co_name,$co_pw) or die(mysql_error()); mysql_select_db($co_db) or die(mysql_error()); ?> 3. And now, finally, the last part: writing the shoutbox itself.<html> <head> <title>Shoutbox!</title> <style type="text/css"> <!-- .message { color: #000000; font-family: Verdana; font-size: 10px;} .username { color: #FF9900 font-family: Verdana; font-size: 10px; font-weight: bold} .date { color: #707070; font-family: Verdana; font-size: 9px;} .forms { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10 px; color: #6CA05A; text-decoration: none; background-color: #CCCCCC; border-color: #6CA05A; border-style: solid; border: 1px} .submit { background-color: #CCCCCC; border-color: #6CA05A; color: #2A343C; font-family: Verdana; font-size: 10px; border-style: solid; border 1 px;} --> </style> </head> <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" style="padding: 2px"> <?php // If submitted if($_POST['submit']) { // Verify if the fields were filled. if(!$_POST['username']) { echo 'Error, You need to post your Username!'; die; } if(!$_POST['email']) { echo 'Error, You need to post your Email!'; die; } if(!$_POST['message']) { echo 'Error, You need to post a Message!'; die; } // Date format $date = date("d/m/y"); // http://http://de2.php.net/manual/de/function.date.php // Assign variables of the forms $username = $_POST['username']; $email = $_POST['email']; $message = $_POST['message']; $ip = $_SERVER['REMOTE_ADDR']; // Connect to the database include('connect.php'); // Insert the info in the shoutbox table. $query = "INSERT INTO shoutbox (username, email, message, date, ip) VALUES ('$username','$email','$message','$date','$ip')"; mysql_query($query); // close connection mysql_close(); // Show message to let them return to the shoutbox ?> <div align="center">Thank you for submitting.<br> Return to the <a href="shoutbox.php">shoutbox</a>! <?php // If NOT submitted } else { // connect to the database include('connect.php'); $query = "SELECT * FROM shoutbox ORDER BY id DESC LIMIT 10"; $result = mysql_query($query); // Create a table ?> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <? // Run a While loop for the rows while($c = mysql_fetch_array($result)) { ?> <tr> <td><a href="mailto:<? echo $c[email] ?>"> <? echo $c[author] ?></a> says: <div align="justify"><? echo $c[message] ?></div> </td> </tr> <tr><td>on <? echo $c[date] ?> <hr noshade="noshade" size="1" style="border-style: dashed" color="#000000" /></td></tr> <? } ?> </table> <form method="post" action="shoutbox.php"> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td>Username :</td> <td><input type="text" name="username" class="forms"></td> </tr> <tr> <td>Email :</td> <td><input type="text" name="email" class="forms"></td> </tr> <tr> <td>Message :</td> <td><input type="text" name="message" class="forms"></td> </tr> <tr> <td colspan="2"><input type="submit" name="submit" value="Speak!" class="subtmit"></td> </tr> </table> </form> <? } mysql_close(); ?> </body> </html> Save it and call it shoutbox.php.if you have any questions don't be shy and ask me here: odirima@walla.co.il Share this post Link to post Share on other sites
iGuest 3 Report post Posted November 29, 2004 Can you do it for me...PM me if you can! Share this post Link to post Share on other sites
iGuest 3 Report post Posted December 1, 2004 But this is a very easy way to do it What is your problem? Share this post Link to post Share on other sites
iGuest 3 Report post Posted December 2, 2004 dude! just use dreamweaver to make it The code.. ? You know it! Share this post Link to post Share on other sites
iGuest 3 Report post Posted December 22, 2004 If your confused on the tables, just use PHPmyadmin, very simple. Share this post Link to post Share on other sites
iGuest 3 Report post Posted December 22, 2004 odirima you have a few areas with your script! Â heres the changes: Â 1. $c[author] was not a vaild value change to $c['username'] Â 2. change: $c to $c['email'] $c[message] to $c['message'] $c [date] to $c['date'] Â As you for got to wrap email, message and date with two ' Â hay man good tutorial! but a few errors! which I have corrected! Share this post Link to post Share on other sites
iGuest 3 Report post Posted December 23, 2004 I use the shoutbox from http://forums.xisto.com/no_longer_exists/ , and it's pretty easy to use though! Share this post Link to post Share on other sites
iGuest 3 Report post Posted December 24, 2004 Hi,This is great!!!you written it?Again COOOOOOOOL!!!bye... Share this post Link to post Share on other sites
iGuest 3 Report post Posted December 25, 2004 Yes, it's great.I will install that.Thank you. Share this post Link to post Share on other sites
iGuest 3 Report post Posted December 30, 2004 i'll check this and probably post it in my site. Share this post Link to post Share on other sites
iGuest 3 Report post Posted December 31, 2004 seems hardby the way bass i added you to xfire Share this post Link to post Share on other sites
iGuest 3 Report post Posted January 4, 2005 Its working so far, thanks but i dont know how to alter the style of text that shows on the shoutbox, like colour and font. Can anyone help? thanks Share this post Link to post Share on other sites
iGuest 3 Report post Posted January 4, 2005 .message {color: #000000;font-family: Verdana;font-size: 10px;}here edit the fields Share this post Link to post Share on other sites