Untitled
unknown
plain_text
3 years ago
1.3 kB
0
Indexable
Never
<?php include_once '../autoloader.php'; session_start(); if(isset($_SESSION['customer'])) unset($_SESSION['customer']); function EmptyString($str) { return !(isset($str) && (strlen(trim($str)) > 0)) && $str !== "0"; } if(isset($_POST['submit-btn'])){ unset($_POST['submit-btn']); $products = new Products; foreach($_POST as $key => $value){ if(!EmptyString($_POST[$key]) && intval($value) >= 0) $products->setInfo($key, intval($value)); else { header('Location: ../../order?err=emptyString:'.$key); $_POST = array(); unset($products); exit(); } } if(str_starts_with($products->validate(), "err#")){ $error_msg = array_pop(explode("#", $products->validate())); header('Location: ../../order?err='.$error_msg); $_POST = array(); exit(); } else{ $customer = new Customer; $customer->products_ordered = $products; $_SESSION['customer'] = serialize($customer); header('Location: ../../checkout'); $_POST = array(); exit(); } } else{ header('Location: ../../order?err=unvalidated'); $_POST = array(); exit(); }