<?php
include_once("../config/templateConfig.inc.php");
include_once("../config/databaseConfig.inc.php");
include_once("../adodb/mylib.inc.php");
$templateMain   = new SmartTemplate('tip.html');
$templateMenu   = new SmartTemplate('menu.html');
$templateTop    = new SmartTemplate('top.html');
$templateBottom = new SmartTemplate('copyRight.html');
/*
输出头部
*/
$templateTop->output();
/*
输出菜单
*/
$menu="在线DIY";
$submenu="";
$templateMenu->assign('MENU',$menu);
$templateMenu->output();
/*
获取变量
*/
$Qname      = $_POST["name"];
$Qtel       = $_POST["tel"];
$Qaddr      = $_POST["addr"];
$Qinfo      = $_POST["info"];
$Qorder     = $_POST["order"];
$tprice     = $_POST["tprice"];
$hasbug     = false;
if (empty($tprice)==true){
	$hasbug = true;
    $thetip = "定单不能为空！";
}else{
	if (empty($Qname)==true || empty($Qtel)==true){
		$hasbug = true;
	    $thetip = "姓名和电话不能为空！";
	}else{
		$Qinfo      = mysubstr($Qinfo,0,250);
	}
}
/*
写记录
输出主体部分
*/
if (!$hasbug){
$sql = "SELECT * FROM DiyOrder WHERE ID = -1"; 
$rs = $db->Execute($sql); 
$record = array(); 
$record["Dname"]  = $Qname;
$record["Dtel"]   = $Qtel;
$record["Daddr"]  = $Qaddr;
$record["Dinfo"]  = $Qinfo;
$record["Dorder"] = $Qorder;
$insertSQL = $db->GetInsertSQL($rs, $record,true);
$db->Execute($insertSQL); 
$rs->close();
$db->close();
}
$thetip == "" ? $thetip="DIY下单成功！" : $thetip = $thetip;
$templateMain->assign('THETIP',$thetip);
$templateMain->output();
/*
输出页脚
*/
$templateBottom->output();
?>