ob_start();
require_once("../dbconnect.php");
$conn = DBConnect();
session_start();
$sql = "select `id` from `admin` where `id`='$_SESSION[admin_id]' and `pass`='$_SESSION[pass]'";
$result = $conn->query($sql);
if(!mysqli_fetch_array($result))
header("Location:index.php");
else
{
$type = $_POST[type];
$amount = $_POST[amount];
if($type == "sign")
$str = "SIGN-";
if($type == "expend")
$str = "EXPD-";
for($i=0; $i < 12; $i++)
{
$str .=sprintf("%c",rand(65, 90));
if($i == 3||$i == 7)
$str .= "-";
}
}
$sql = "INSERT INTO `coupon`(`code`, `type`, `amount`,`owner`,`create_date`,`exp_date`) VALUES ('".$str."','".$type."',".$amount.",'".$_SESSION[admin_id]."',timestamp(now()),ADDDATE(timestamp(now()), INTERVAL 30 DAY))";
$result = $conn->query($sql);
header("main.php?tab=mycoupon");
mysqli_close();
댓글 0