PHP Code:
<?php
$db = "mplionhe_announ"; // name of your database
$user = "mplionhe"; // username for your database
$password = "pass"; // password for your database
// make the connection
$link = mysql_connect("localhost", $user, $password);
if (!$link) die ("cant connect to mysql");
//select the database once connected.
mysql_select_db($db, $link) or die ("cannot connect to $db");
// handle the posted variables
$content = $_POST['content'];
$content = addslashes($content);
// handle the posted variables
$date = $_POST['date'];
$date = addslashes($date);
// Now insert the data into the Database
// tablename is the name of your table
// (content,url,date) are the names of the fields in your table
// $content, $url, now() specify the values to insert into the table
// $content and $url are the variable names from above
// now() inserts the current date
$submit = $_POST['submit'];
if($submit)
{
$query=" INSERT INTO weekly (content,date) VALUES ( '$content', '$date' ) " or die("Bad query: " . mysql_error()) ; // do database additons
}
else
{
// do your input form
}
$result=mysql_query($query);
if ($result) {
echo "Your information has been added to the database";
} else {
echo "Sorry, your information has not been added";
}
?>
Heres the full code, however, now that my form is working, at http://www.mplionhearts.com/phptesti...ouncements.php it wont succesfully insert the information. Go ahead and try it, see what happens.
Bookmarks