null !== $_POST['name'] ? htmlspecialchars($_POST['name']) : '', 'zip' => null !== $_POST['zip'] ? htmlspecialchars($_POST['zip']) : '', 'prefecture' => null !== $_POST['prefecture'] ? htmlspecialchars($_POST['prefecture']) : '', 'city' => null !== $_POST['city'] ? htmlspecialchars($_POST['city']) : '', 'address1' => null !== $_POST['address1'] ? htmlspecialchars($_POST['address1']) : '', 'address2' => null !== $_POST['address2'] ? htmlspecialchars($_POST['address2']) : '', 'country' => null !== $_POST['country'] ? htmlspecialchars($_POST['country']) : '', 'email' => null !== $_POST['email'] ? htmlspecialchars($_POST['email']) : '', ]; if (isset($_POST['topayment'])) { if (!isset($_POST['name']) || $_POST['name'] == '') $errcheck['name'] = $eigo ? 'Name' : 'お名前'; if (!isset($_POST['zip']) || $_POST['zip'] == '') $errcheck['zip'] = $eigo ? 'ZIP Code' : '郵便番号'; if (!isset($_POST['prefecture']) || $_POST['prefecture'] == '') $errcheck['prefecture'] = $eigo ? 'State/Province/Prefecture' : '都道府県'; if (!isset($_POST['city']) || $_POST['city'] == '') $errcheck['city'] = $eigo ? 'City/Town' : '市区町村'; if (!isset($_POST['address1']) || $_POST['address1'] == '') $errcheck['address1'] = $eigo ? 'Address 1' : '町名+番地'; if (!isset($_POST['country']) || $_POST['country'] == '') $errcheck['country'] = $eigo ? 'Country' : '国'; if (!isset($_POST['email']) || $_POST['email'] == '' || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) $errcheck['email'] = $eigo ? 'Email' : 'メール'; unset($_POST['topayment']); if (count($errcheck) > 0) { $err = $eigo ? 'Please check the following fields:' : '下記のフィールドをご確認下さい:'; echo $err .= '
'; foreach ($errcheck as $e) { $err .= $e.'
'; } } else { $step = 2; } } else if (isset($_POST['complete'])) { dd($_POST); // TODO // ・QRコード及びアドレスの表示 // ・支払いの確認 // ・支払いIDと配送情報をDBに入って、メールの送信 // ・管理者は毎日午後5時(日本時間)まで手動で確認すると、翌日午前12時(日本時間)配送予定ってメッセージの表示 // ・郵便局で配送すると、午後3時(日本時間)までメールで郵便追跡番号を送る // ・3日間後、配送情報は自動でDBから削除される(crontab) } $total = 0; $cart = array_filter(explode(',', getcookie('cart'))); $sql = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } foreach ($cart as $c) { if ($stmt = mysqli_prepare($sql, 'SELECT price FROM item WHERE slug = ?')) { mysqli_stmt_bind_param($stmt, 's', $c); mysqli_stmt_execute($stmt); mysqli_stmt_bind_result($stmt, $price); mysqli_stmt_fetch($stmt); mysqli_stmt_close($stmt); if (!isset($items[$c])) $items[$c] = [ 'price' => $price, 'count' => 1 ]; else $items[$c]['count']++; } } mysqli_close($sql); if ($err != '') { ?>