Hey bud is this right way?
Code:
header("refresh: 3; url=message_board.php");
<?php // Script 12.5 - add_entry.php
// This script adds an entry to the database.
// Address error handing.
ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);
if (isset ($_POST['submit'])) { // Handle the form.
// Connect and select.
if ($dbc = @mysql_connect ('localhost', 'postc3', 'jesy+qrp')) {
if (!@mysql_select_db ('msgboard')) {
die ('<p>Could not select the database because: <b>' . mysql_error() . '</b></p>');
}
} else {
die ('<p>Could not connect to MySQL because: <b>' . mysql_error() . '</b></p>');
}
// Define the query.
$query = "INSERT INTO entry (name, message, date) VALUES ('{$_POST['from']}', '{$_POST['message']}', NOW())";
// Execute the query.
if (@mysql_query ($query)) {
print '<p>The message has been added.</p>';
} else {
print "<p>Could not add the message because: <b>" . mysql_error() . "</b>. The query was $query.</p>";
}
mysql_close();
}
// Display the form.
?>
<form action="form.php" method="post">
<p>From: <input type="text" name="from" size="40" maxsize="100" /></p>
<p>Message: <textarea name="message" cols="40" rows="5"><?php
$message = $_GET['msg'];
if(isset($message))
print "Enter your message here: ";
?></textarea></p>
<input type="submit" name="submit" value="Submit" /></form>
</body>
</html>