<?Php
/*
* @author Istvan Franko
* @copyright 2014
*/

session_start();


if (!isset($_SESSION['loggedin'])) 
{
  $_SESSION['loggedin'] = '0'; 
}
?>

<html>

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

<body>

<?php
if ($_SESSION['loggedin'] =1){
	//user in logen in. Show a message on the screen
	echo "I can see that you are logged in<hr/>";
} else {
	//redirect the user to the login form.
	session_destroy();
	header('Location: login.php');
}
?>

<div id="container">

	<div id="header">
	<! header picture in css >
	</div>
	
	<div id="navigation">
		<?php include 'navigation.php'; ?>
	</div>

<?php
$con = mysql_connect("localhost","******","******");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

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

//get the ID from the querystring.

$id=$_GET['id']; //get the value from the address bar
if(!is_numeric($id))
{ //check is a number.
echo "Sorry, there appears to have been an error.";
exit;
}

$query=Mysql_query("SELECT * FROM php_films WHERE filmid=$id ");
$row=mysql_fetch_object($query);
echo mysql_error();


//get the value of each column and add to local variables
$filmid = $row->filmid;
$filmtitle = $row->filmtitle;
$filmyear = $row->filmyear;
$filmrating = $row->filmrating;
$filmdesc = $row->filmdesc;
$filmtrailer = $row->filmtrailer;
$filmofficialurl = $row->filmofficialurl;
$filmcert = $row->filmcert;

//close the connection to the database.

mysql_close($con);
?> 



<div id="aside">
<form method="LINK" action="films2.php">
<input type="submit" value="Ignore">
</form>
</div>

<div id="content">

<h1>Update an exiting film in the database</h1>

<form action="update-film.php" method="post">

Film ID: <input type="text" name="filmid" size="10" value="<?php echo $filmid; ?>" readonly="readonly"><br><br>

Film title: <input type="text" name="filmtitle" size="40" value="<?php echo $filmtitle; ?>"><br><br>
Year: <input tyoe="text" name="filmyear" size="10" value="<?php echo $filmyear; ?>"><br><br>
Rating of film: <input type="text" name="filmrating" size="10" value="<?php echo $filmrating; ?>"><br><br>
Description: <input type="text" name="filmdesc" value="<?php echo $filmdesc; ?>"><br><br>
Trailer: <input type="text" name="filmtrailer" size="60" value="<?php echo $filmtrailer; ?>"><br><br>
Official URL: <input type="text" name="filmofficialurl" size="60" value="<?php echo $filmofficialurl; ?>"><br><br>
Certificate: <input type="text" name="filmcert" value="<?php echo $filmcert; ?>"><br><br>

<input type="submit" value="Update">

</from>

</div>

<div id="footer">
Copyright &#169; Istvan Franko, 2014
</div>


</div>
</body
</html>
