I believe that my problem is with the isset on line 7 and 39, but I do not know of anyway around it. Can someone enlighten me.
<?php
session_start();
if (isset($_GET['logout'])){
unset($_SESSION['logged_in']);
}
?>
<html>
<head>
<title>Add a New Car!</title>
<?php
if (isset($_POST['submit'])) {
//print_r($_POST);
$password = md5($_POST['password']);
//echo'<p>'.$password.'</p>';
$username = ($_POST['username']);
//echo'<p>'.$username.'</p>';
}
$db = new PDO('sqlite:login.sqlite');
$login = 'SELECT * FROM login
WHERE userid="'.$username.'"
AND password="'.$password.'";';
//echo'<p>'.$login.'</p>';
$attempt = $db->query($login);
foreach ($attempt as $row) {
//print_r($row);
$_SESSION['logged_in'] = $username;
}
?>
</head>
<body>
<?php
if (!isset($_SESSION['logged_in'])){
?>
<form method="post" action="Db_login.php">
<p>Username:<br /><input type="text" name="username" /> </p>
<p>Password:<br /><input type="password" name="password" /></p>
<p><input type="submit" name="submit" value="Log In!" /></p>
</form>
<?php
} else {
?>
<?php
if(isset($_POST['submit'])) {
print_r($_POST);
$make = ($_POST['make']);
$model = ($_POST['model']);
$year = ($_POST['year']);
$fuel = ($_POST['fuel_type']);
$vin = ($_POST['vin_number']);
$reg = ($_POST['reg_number']);
}
$db = new PDO('sqlite:cars.sqlite');
$sqlCars = 'INSERT INTO cars ( )
VALUES("'.$make.'","'.$model.'","'.$year.'","'.$fuel.'","'.$vin.'","'.$reg.'");';
echo'<p>'.$sqlCars.'</p.>';
?>
<form method="post" action="Db_new_Cars.php" enctype="multipart/form-data">
<p>Make:<br /><input type="text" name="make" /> </p>
<p>Model:<br /><input type="text" name="model" /></p>
<p>Year:<br /><input type="text" name="year" /></p>
<p>Fuel Type:<br /><input type="text" name="fuel_type" /></p>
<p>Vin Number:<br /><input type="text" name="vin_number" /></p>
<p>Reg Number:<br /><input type="text" name="reg_number" /></p>
<p>Choose a image to upload:<br />
<input type="file" name="myfile"></input></p>
<p><input type="submit" name="submit" value="Submit!" /></p>
</form>
<h1> Protected Content!</h1>
<p>You are logged in as <em><?php echo $_SESSION['logged_in']; ?> </em></p>
<p><a href="Db_login.php?logout=true">Log out!</a></p>
<p><a href="New_Cars.php">Add a new car</a></p>
<p><a href="Book_Out_Cars.php">Book out a car</a></p>
<?php
}
?>
</body>
</html>