我一定是瞎了眼,或者是累了.我找不到错误的来源 错误是"Parse Error:语法错误,文件意外结束",并引用代码的最后行号.我错过了什么.此外,代码的任何一般PHP提示也将受到欢迎.我上完大学课程才学了8周的PHP
<?php include '../view/header.php'; ?>
<?php require('../model/database.php');?>
<?php
$email = filter_input(INPUT_POST, 'email');
if ($email == '')
{
$error = 'Email cannot be blank. Please enter a valid email.';
require_once('index.php');
exit();
}
$query = 'SELECT customerID, firstName, lastName, email
FROM customers
WHERE email = :email';
$statement = $db->prepare($query);
$statement->bindValue(':email', $email);
$statement->execute();
$customer = $statement->fetch();
$statement->closeCursor();
if ($customer['email'] != $email)
{
$error = 'No matching email. Please enter a valid email.';
require_once('index.php');
exit();
}
$query = 'SELECT productCode
FROM products
ORDER BY productCode';
$statement = $db->prepare($query);
$statement->execute();
$productCodes = $statement->fetchAll();
$statement->closeCursor();
?>
<main>
<h2>Register Product</h2>
<p></p>
<form action="product_registered.php" method="post" id="aligned">
<input type="hidden" name="customerID"
value="<?php echo $customer['customerID']; ?>">
<label>Customer:</label>
<label><?php echo htmlspecialchars($customer['firstName'] . ' ' . $customer['lastName']); ?></label>
<br>
<label>Product:</label>
<select name="productCode">
<?php foreach ($productCodes as $productCode): ?>
<option value="<?php echo htmlspecialchars($productCode['productCode']); ?>">
<?php echo htmlspecialchars($productCode['name']); ?>
</option>
</select>
<br>
<label> </label>
<input type="submit" value="Register Product" /><br>
</form>
</main>
<?php include '../view/footer.php'; ?>