saleLogging.css
#webhead{
/*
background-color:gray;
*/
text-align:center;
}
span {
color:red;
width:100px;
}
saleLogging.php
<pre class="php" name="code"><html>
<head>
<meta charset="UTF-8">
</head>
<body>
<?php
//设置时区
date_default_timezone_set("PRC");
echo "货号:" . $_POST["goodsIdent"] . "<br>";
echo "数量:" . $_POST["saleCounts"] . "<br>";
echo "售价:". $_POST["salePrice"] . "<br>";
echo "优惠金额:" . $_POST["discountPrice"] . "<br>";
echo "成交金额:" . $_POST["dealPrice"] . "<br>";
echo "售货员:" . $_POST["saler"] . "<br>";
echo "会员电话:" . $_POST["memPhone"] . "<br>";
$currentTime = date("y-m-d H:i:s",time());
//连接数据库
$con = mysql_connect("localhost","root","root123");
if (!$con) {
die("Could't not connect: " . mysql_error());
}
//数据库操作
//创建数据库
/*if (mysql_query("create database my_db",$con)) {
echo "Database created.";
} else {
echo "Error creating database:" . mysql_error();
} */
//选择数据库
mysql_select_db("my_db",$con);
//建表
$sql="create table t_sale_detail
(
id int(10) NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
goodsIdent varchar(20),
saleCounts int(5),
saleDate datetime,
salePrice double(10,2),
discountPrice double(10,2),
dealPrice double(10,2),
saler varchar(10),
memPhone varchar(15),
isStock varchar(10)
);";
//执行sql
if (!mysql_query($sql,$con)){
echo "ERROR:create table error." . mysql_error() . "<br>";
};
$insertSql="insert into t_sale_detail(
goodsIdent,
saleCounts,
saleDate,
salePrice,
discountPrice,
dealPrice,
saler,
memPhone) values (
'$_POST[goodsIdent]',
'$_POST[saleCounts]',
'$currentTime',
'$_POST[salePrice]',
'$_POST[discountPrice]',
'$_POST[dealPrice]',
'$_POST[saler]',
'$_POST[memPhone]'
);";
if (!mysql_query($insertSql, $con)){
echo "ERROR:insert table t_sale_detail error." . mysql_error() . "<br>";
};
//关闭数据库
mysql_close($con);
?>
</body>
</html>