<?php session_start(); require_once 'includes/connect.php'; require_once 'includes/functions.php'; if ($_SESSION["userID"] != "") { //Upload File if (isset($_POST['submit'])) { //Import uploaded file to Database $handle = fopen($_FILES['fileToUpload']['tmp_name'], "r"); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { _addCoupon($data[0]); } fclose($handle); } else { header('Location: upload.php'); exit; } header('Location: dashboard.php'); exit; } else { header('Location: login.html'); exit; } ?>
function addCoupon() { $code = $_POST['code']; $discount = $_POST['discount']; _addCoupon($code, $discount); }