- Customer types in a model number (along with a quantity of course)
- Customer submits the form
- OOPS there is an error
- A new "small" window pops up and tells the customer "Were sorry the Item you have entered is no longer available."
So how would this be coded? because to be honest Im not sure where to even begin on how to do this with PHP.
Here is the script I have created upto now.
Code: Select all
<?php
define("PHPINCDIR","../../phpinc/");
include ('ez_db.php');
require_once(PHPINCDIR.'ez_html_family.php');
require_once(PHPINCDIR.'ez_class_page.php');
require_once(PHPINCDIR."quotefunctions.php");
if (!empty($_POST['prod_quantity']) AND !empty($_POST['model'])){
$_SESSION['prod_quantity'][$_POST['model']] = $_POST['prod_quantity'];
} elseif (!empty($_POST['cart_quantity'])){
// update qty in cart session after submit
for ($i=0; $i<count($_SESSION['prod_quantity']); $i++){
if ($_POST['cart_quantity'][$i] >= 1){
$_SESSION['prod_quantity'][$_POST['cart_id'][$i]] = $_POST['cart_quantity'][$i];
} else {
$_SESSION['prod_quantity'][$_POST['cart_id'][$i]] = '';
unset($_SESSION['prod_quantity'][$_POST['cart_id'][$i]]);
}
}
}
if (is_array($_SESSION['prod_quantity'])){
foreach ($_SESSION['prod_quantity'] AS $prod=>$qty){
$sql = mysql_query("SELECT * FROM product WHERE model='$prod'");
$row = mysql_fetch_array($sql);
echo '<a href="p.php?n='.$row['id'].'">'.$row['model'].'</a> '.$row['little_desc']."\n";
echo "<input type=\"text\" name=\"cart_quantity[]\" value=\"$qty\" size=\"2\" maxlength=\"4\" style=\"width: 40px\" class=\"quanw\">
<input type=\"hidden\" name=\"cart_id[]\" value=\"$prod\"><br />";
}
}
?>