For this tutorial, you will need an sql host, if you dont have one, you can get it in http://freesql.org
1. Create a new table, for that, run this code
CODE
CREATE TABLE `shoutbox` (
`id` int(11) NOT NULL auto_increment,
`name` text NOT NULL,
`message` longtext NOT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM;
`id` int(11) NOT NULL auto_increment,
`name` text NOT NULL,
`message` longtext NOT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM;
2. Now make a new document and paste this code
CODE
<style type="text/css">
<!--
body,td,th {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #000000;
}
-->
</style><table width="200" height="200" border="0">
<tr>
<td><iframe scrolling="auto" src="show.php">
</iframe>
</td>
</tr>
</table>
<form action="shoutbox2.php" method="post">
<p>Name<br>
<input name="name_txt" type="text" id="name_txt">
</p>
<p>Message<br>
<textarea name="message_txt" id="message_txt"></textarea>
</p>
</p>
<p>
<input type="submit" name="Submit" value="blah">
</p>
</form>
<!--
body,td,th {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #000000;
}
-->
</style><table width="200" height="200" border="0">
<tr>
<td><iframe scrolling="auto" src="show.php">
</iframe>
</td>
</tr>
</table>
<form action="shoutbox2.php" method="post">
<p>Name<br>
<input name="name_txt" type="text" id="name_txt">
</p>
<p>Message<br>
<textarea name="message_txt" id="message_txt"></textarea>
</p>
</p>
<p>
<input type="submit" name="Submit" value="blah">
</p>
</form>
Save it as shout.php
In that code, im bassically making the "form" and the "style"
2. Make nother document, and paste this code
CODE
<style type="text/css">
<!--
body,td,th {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #000000;
}
-->
</style><?
$name= $_POST["name_txt"];
$message= $_POST["message_txt"];
mysql_connect("localhost","your_username","your_pass");
mysql_select_db("your_database");
MYSQL_QUERY("INSERT INTO shoutbox (id,name,message)".
"VALUES ('NULL','$name', '$message')");
?>
<?
echo "Shout posted, <a href=shout.php>go back</a>"
?>
<!--
body,td,th {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #000000;
}
-->
</style><?
$name= $_POST["name_txt"];
$message= $_POST["message_txt"];
mysql_connect("localhost","your_username","your_pass");
mysql_select_db("your_database");
MYSQL_QUERY("INSERT INTO shoutbox (id,name,message)".
"VALUES ('NULL','$name', '$message')");
?>
<?
echo "Shout posted, <a href=shout.php>go back</a>"
?>
Now save it as shoutbox2.php . Here i aply style too but im sending the form too
3. Make another document and paste this code
CODE
<style type="text/css">
<!--
body,td,th {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #000000;
}
-->
</style><?
mysql_connect("freesql.org","spoono_db","pokemon") or die(mysql_error());
mysql_select_db("spoono_db") or die(mysql_error());
$query = "SELECT message, name
FROM shoutbox order by id DESC LIMIT 10";
$result = mysql_query($query);
echo "<TABLE>";
while($r=mysql_fetch_array($result))
{
echo "<TR>
<TD><font-size: 10px;>
<strong>$r[name]</A></font></TD></strong>
</TR>
<TR>
<TD><font-size: 10px;>$r[message]</font></TD>
</TR>
<TR>
<TD><HR></TD>
</TR>";
}
echo "</TABLE>";
?>
<!--
body,td,th {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #000000;
}
-->
</style><?
mysql_connect("freesql.org","spoono_db","pokemon") or die(mysql_error());
mysql_select_db("spoono_db") or die(mysql_error());
$query = "SELECT message, name
FROM shoutbox order by id DESC LIMIT 10";
$result = mysql_query($query);
echo "<TABLE>";
while($r=mysql_fetch_array($result))
{
echo "<TR>
<TD><font-size: 10px;>
<strong>$r[name]</A></font></TD></strong>
</TR>
<TR>
<TD><font-size: 10px;>$r[message]</font></TD>
</TR>
<TR>
<TD><HR></TD>
</TR>";
}
echo "</TABLE>";
?>
Here i apply style too
save this as show.php.
4. Now upload all the files to your server and enjoy your shoutbox