错误!
发生以下错误: 注意:未定义的变量:第75行的C:\ Program Files(x86)\ EasyPHP-DevServer-13.1VC9 \ data \ localweb \ scripts \ ladies_paradise \ checkout.php中的错误
请再试一次。 ` 无标题文档
<body>
<?php
$page_title='ORDER FORM';
if(isset($_POST['submitted'])){
$errors= array();
$price=($_POST['price']);;
$quantity=($_POST['quantity']);
$total = $quantity * $price;
$total = number_format ($total, 2);
// Validate the name and combat Magic Quotes, if necessary.
if (empty ($_POST['product'])) {
$errors[]='You forgot to enter product.';
}else{
$pr=trim($_POST['product']);
}
// Validate the price.
if (empty ($_POST['price'])) {
$errors[] ='You forgot to enter price.';
} else {
$p=trim($_POST['price']);
}
// Validate the quantity.
if (empty ($_POST['quantity'])) {
$errors[] ='You forgot to enter quantity.';
} else {
$q=trim($_POST['quantity']);
}
if(empty($errors)){
require_once('checkout_connect.php');
$query="INSERT INTO customers(product,price,quantity)VALUES('$pr','$p','$q')";
$result=@mysql_query($query);//Run the query.
if($result){
echo 'You are purchasing <b>', $c. '</b>.
Total price is <b>$', $total, '</b>.';
} else { // One from element was not filled out properly.
echo '<p><font color="orange">Please go back and fill out the form again.</font></p>';
}
exit();
}else{ //If it did not run OK.
echo '<h1 id="mainhead">System Error</h1>
<p class="error">You could not registered due to system error.We apologize for any inconvenience.</p>';//Public message.
echo '<p>'.mysql_error().'<br/><br/>'.$query.'</p>'; //Debugging message.
exit();
}
mysql_close(); //Close the database connection.
}else{ //Report the errors.
echo '<h1 id="mainhead">Error!</h1>
<p class="error">The following error(s) occurred:<br />';
if (is_array($errors)) {
foreach ($errors as $msg){ //Print each error.
echo " - $msg<br />\n";
}
}
echo '</p><p>Please try again.</p><p><br /></p>';
}//End of if (empty($errors)) IF.
?>
<h2>ORDER FORM:</h2>
<form action="checkout.php" method="post">
<p>Product: <input type="number" name="code_item" size="15" maxlength="15" value"<?php if (isset($_POST['product'])) echo $_POST['product']; ?>" /></p>
<p>Price: <input type="number" name="price" size="15" maxlength="30" value"<?php if (isset($_POST['price'])) echo $_POST['price']; ?>" /></p>
<p>Quantity: <input type="number" name="quantity" size="30" maxlength="50" value"<?php if (isset($_POST['quantity'])) echo $_POST['quantity']; ?>" /></p>
<p><input type="submit" name="submit" value="Submit" /></p>
<input type="hidden" name="submitted" value="TRUE" />
</form>
</body>
</html>``
答案 0 :(得分:0)
将其定义在文档的顶部。
<?php
$errors = false;
或者,检查是否使用需要分配的三元组进行设置。
echo isset($errors) ? $errors: '';
''
可以替换为与要求相关的任何分配。