<html>

<head>
<title>Films</title>
<link rel="stylesheet" type="text/css" href="css/guestbookform.css" />
</head>

<body>

<?php
echo "<h1> Insert Films</h1>";
echo "<br>";
$con = mysql_connect("localhost","******","******");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("******", $con);


//get  the values posted from the form (i.e. what user entered in the form) and add them to local variables

$filmtitle = $_POST['filmtitle'];
$filmyear = $_POST['filmyear'];
$filmrate = $_POST['filmrate'];
$filmdesc = $_POST['filmdesc'];
$filmcover = $_POST['filmcover'];
$filmtrailer = $_POST['filmtrailer'];
$filmofficialurl = $_POST['filmofficialurl'];
$filmcert = $_POST['filmcert'];

//construct a valid SQL statement that will be send to the database server.
$sql="INSERT INTO php_films (filmtitle,filmyear,filmrating,filmdesc,filmcover, filmtrailer,filmofficialurl,filmcert) VALUES
('$filmtitle', '$filmyear', '$filmrate', '$filmdesc', '$filmcover', '$filmtrailer', '$filmofficialurl', '$filmcert')";

//display the SQL we will sent to server -  for debugging only

echo $sql;

// run the SQL query on the server (i.e. send the SQL to the database server)

if (!mysql_query($sql,$con))
{
die ('Error: ' . mysql_error());
}

echo "<h1>1 record added to the database.</h1>";

//close the connection to the database.

mysql_close($con); 

?>

<br><br>
<form method="LINK" action="films2.php">
<input type="submit" value="Back to list">
</form>

</body>
</html>