-
Notifications
You must be signed in to change notification settings - Fork 0
/
saveGoods.php
41 lines (34 loc) · 1.15 KB
/
saveGoods.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
header("Content-Type:text/html;charset=utf-8");
//1、接受商品表的数据(用户输入的数据)
$goodsId = $_REQUEST['goodsId'];
$goodsName = $_REQUEST['goodsName'];
$goodsPrice = $_REQUEST['goodsPrice'];
$goodsCount = $_REQUEST['goodsCount'];
$goodsDesc = $_REQUEST['goodsDesc'];
$goodsImg = $_REQUEST['goodsImg'];
$goodsSpecs = $_REQUEST['goodsSpecs'];
//2、数据保存在数据库中
//1)、建立连接(搭桥)
$conn = mysql_connect("localhost","root","root");
if(!$conn){
die("数据库连接失败:".mysql_error());
}
//2)、选择数据库(找目的地)
if(!mysql_select_db("shiseidodb",$conn)){
die("数据库选择失败".mysql_error());
};
//3)、传输数据(过桥)
$sqlstr = "insert into goodsInfo values('".$goodsId."','".$goodsName."','".$goodsPrice."','".$goodsCount."','".$goodsDesc."','".$goodsImg."'
,'".$goodsSpecs."')";
$count = mysql_query($sqlstr,$conn);
if(!$count){
die('插入失败!'.mysql_error());
}
//4)、关闭连接(拆桥)
mysql_close($conn);
//3、给客户端返回(响应)一个注册成功!
if($count>0){
echo "保存成功";
}
?>