Hi Guys,
I am trying to insert data via a form into a table in a mysql database called cms_stories.
What I want it to do is:
1) check all the fields have been filled in
2) If that condition is true post the information entered into the database
Then when those conditions are true
3) Output text stating that the information has been entered into the database
4) Show what has been entered in each field
But am having trouble - Could someone please cast their eye over this and advise if this format of the statements seems correct.
Thanks
Chris
<?php
session_start();
//Connect to DB
include("***************** ");
// POST variables
$section=$_POST['section'];
$added_by=$_POST['added_by'];
$headline =$_POST['byline_name'];
$appeared=$_POST['appeared'];
$published=$_POST['published'];
$opening=$_POST['opening'];
$body_text=$_POST['body_text'];
$notes=$_POST['notes'];
{
if ((!$section) || (!$added_by) || (!$headline) || (!$byline_name) || (!$appeared) || (!$published) || (!$opening) || (!$body_text) || (!$notes)
Print "You forgot something. Please use your back buton!";
}
} else {
(isset($_POST['Submit'])){
$query = "INSERT INTO cms_stories(section,added_by,headline,byline_name,appeared,published,opening,body_text,notes) VALUES ('$section','$added_by','$headline','$byline_name','$appeared','$published','$opening','$body_text','$notes')";
$msg = "A new Story has been added to the database - Please Click <a href=\"http://index\">Here</a> to return to the main menu";
$link = mysql_connect;
mysql_select_db($db);
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
mysql_close();
// GET variables
$section=$_GET['section'];
$added_by=$_GET['added_by'];
$headline =$_GET['byline_name'];
$appeared=$_GET['appeared'];
$published=$_GET['published'];
$opening=$_GET['opening'];
$body_text=$_GET['body_text'];
$notes=$_GET['notes'];
}
?>