This article brings you relevant knowledge about PHP. It mainly introduces how to implement the product adding function through PHP and write it into the database. Friends who are interested can take a look at it together. I hope it will be helpful to everyone. .
Database Table Code for writing data
<?php include("conn/conn.php"); header ( "Content-type: text/html; charset=gb2312" ); ?> <meta> <title>添加商品</title> <link> <style> <!-- .style1 {color: #FFFFFF} --> </style> <?php include("conn/conn.php");?>
添加商品 |
Save the processing file for writing data
<?php header ( "Content-type: text/html; charset=gb2312" ); //设置文件编码格式 include("conn/conn.php"); if(is_numeric($_POST['shichangjia'])==false || is_numeric($_POST['huiyuanjia'])==false) { echo "<script>alert('价格只能为数字!');history.back();"; exit; } if(is_numeric($_POST['shuliang'])==false) { echo "<script>alert('数量只能为数字!');history.back();</script>"; exit; } $mingcheng=$_POST['mingcheng']; $nian=$_POST['nian']; $yue=$_POST['yue']; $ri=$_POST['ri']; $shichangjia=$_POST['shichangjia']; $huiyuanjia=$_POST['huiyuanjia']; $typeid=$_POST['typeid']; $dengji=$_POST['dengji']; $xinghao=$_POST['xinghao']; $pinpai=$_POST['pinpai']; $tuijian=$_POST['tuijian']; $shuliang=$_POST['shuliang']; $upfile=$_POST['upfile']; if(ceil(($huiyuanjia/$shichangjia)*100)alert('商品".$mingcheng."添加成功!');window.location.href='addgoods.php';"; ?>
The above is the detailed content of Detailed explanation of how to implement the product adding function in PHP and write it to the database. For more information, please follow other related articles on the PHP Chinese website!