This shout box uses two php forms. One for the interface and one to connect to the database and process the information.
After the file has been submitted the user is redirected back to the same page.
<?php
$connect = mysql_connect("localhost","root") or die(mysql_error());$database = mysql_select_db("this_site",$connect);$sql_code = mysql_query("SELECT * FROM shouts ORDER BY id DESC");while($row = mysql_fetch_assoc($sql_code)){$title = $row["title"];
$date = $row["date"];
$article = $row["article"];
echo "<h4>$title</h4><p>Posted on $date</p><p>$article</p>";}
?>
//Start PHP protocol
//Connect to the database
//Select the database
//Variable equals select all from shouts
//Fetch each entry in loop for
//title;
//date;
//article;
//Print message with variables
//End PHP protocol
For shout_box_process.php
<?php
session_start();
$connect = mysql_connect("localhost","root") or die(mysql_error());$database = mysql_select_db("this_site",$connect);$title = strip_tags($_POST["title"]);
$article = strip_tags($_POST["article"]);
$date = date("Y-m-d");if ($title && $article){if (strlen($title)<=3 || strlen($article)<=10){include 'header.php';
echo "<p>The sting length is too short.</p><br />";
echo "<p>Browser will rediret in 3 seconds.</p>";
echo "<meta http-equiv='refresh' content='3; url=shout_box.php'>";
echo "<br />";
include 'footer.php';}
else{$query = mysql_query("INSERT INTO shouts (id,title,date,article)VALUES ('','$title','$date','$article')") or die(mysql_error());include 'header.php';
echo "<h3>Success</h3>";
echo "<p>Submission of <b>$title</b>"
echo "was successfull. Browser will rediret in 3 seconds.";
echo "<meta http-equiv='refresh' content='3; url=shout_box.php'>";
echo "<br />";
include 'footer.php';}
}
?>
//Start PHP protocol
//Start session
//Connect to the database
//Select the database
//Define $title
//Define $article
//Define $date
//Check values
//If sting length of title is less than 3 and/or
//Sting length of artilce is less than 10 then...
//...print header
//Print message
//Print message
//Refresh browser
//Print line break
//Print footer
//Otherwise
//If criteria is met then enter data into shouts database
//Print header
//Print message
//Print message
//Print message
//Refresh browser
//Print line break
//Print footer
//End if
//End PHP protocol