<?php
	session_start();
	include"../../connect/db.php";

	if( isset($_POST['user']) ){

		$user = mysqli_real_escape_string($con,$_POST['user']);
		$code = isset($_POST['code']) ? mysqli_real_escape_string($con,$_POST['code']) : '';
		$amount = isset($_POST['amount']) ? mysqli_real_escape_string($con,$_POST['amount']) : '';
		$status = isset($_POST['status']) ? mysqli_real_escape_string($con,$_POST['status']) : 'active';
		$date = date('Y-m-d H:i:s');

		$sql = mysqli_query($con,"INSERT INTO coupons (user, code, amount, status, date) VALUES ('$user', '$code', '$amount', '$status', '$date')");

		if( $sql ){
			echo "success";
		}
		else{
			echo "error";
		}

	}
	else{
		echo "error";
	}
?>