php网页提示报错:Undefined index: action in E:\wamp\wamp\www\shop\admin\goodsProcess.php on line 6
代码如下:<?phpheader("Content-type:text/html;charset=utf-8");require_once$_SERVER['DOCUME...
代码如下:
<?php
header("Content-type:text/html;charset=utf-8");
require_once $_SERVER['DOCUMENT_ROOT'].'shop/tools.php';
require_once $_SERVER['DOCUMENT_ROOT'].'shop/config.php';
require_once $_SERVER['DOCUMENT_ROOT'].'shop/myclass/SQLHelper.php';
$action=$_GET['action'];
if ($action=="add"){
if (isset($_POST['ok'])){
$goods=$_POST['goods'];
$goods['date']=date("Y-m-d H:i:s");
// var_dump($goods);
// exit();
$query=add_sql($goods, "tb_shop");
$sqlHelper=new SQLHelper($host, $user, $passwd, $dbname);
//new myclass\SQLHelper($host,$user,$passwd,$dbname);
$flag=$sqlHelper->dml($query);
//echo $flag;
//print_r($query);
//exit;
// print_r($sqlHelper->dml($query));
if ($flag){
header("Location:../ok.php");
}else {
header("Location:../error.php");
}
}
}else if ($action=="delete"){
$sqlHelper=new SQLHelper($host, $user, $passwd, $dbname);
$gid=$_GET['gid'];
$query="delete from tb_shop where gid=$gid";
$sqlHelper->dml($query);
header("Location:goodslist.php");
}else if ($action=="update"){//点击更改提交
$sqlHelper=new SQLHelper($host, $user, $passwd, $dbname);
$goods=$_POST['goods'];
$gid=$goods['gid'];
$gname=$goods['gname'];
$num=$goods['num'];
$price=$goods['price'];
$desc=$goods['desc'];
$query="update tb_shop set gname='$gname',num='$num',price='$price',desc='$desc' where gid=$gid";
// print_r($query);
// exit;
$sqlHelper->dml($query);
header("Location:goodslist.php");
}
?> 展开
<?php
header("Content-type:text/html;charset=utf-8");
require_once $_SERVER['DOCUMENT_ROOT'].'shop/tools.php';
require_once $_SERVER['DOCUMENT_ROOT'].'shop/config.php';
require_once $_SERVER['DOCUMENT_ROOT'].'shop/myclass/SQLHelper.php';
$action=$_GET['action'];
if ($action=="add"){
if (isset($_POST['ok'])){
$goods=$_POST['goods'];
$goods['date']=date("Y-m-d H:i:s");
// var_dump($goods);
// exit();
$query=add_sql($goods, "tb_shop");
$sqlHelper=new SQLHelper($host, $user, $passwd, $dbname);
//new myclass\SQLHelper($host,$user,$passwd,$dbname);
$flag=$sqlHelper->dml($query);
//echo $flag;
//print_r($query);
//exit;
// print_r($sqlHelper->dml($query));
if ($flag){
header("Location:../ok.php");
}else {
header("Location:../error.php");
}
}
}else if ($action=="delete"){
$sqlHelper=new SQLHelper($host, $user, $passwd, $dbname);
$gid=$_GET['gid'];
$query="delete from tb_shop where gid=$gid";
$sqlHelper->dml($query);
header("Location:goodslist.php");
}else if ($action=="update"){//点击更改提交
$sqlHelper=new SQLHelper($host, $user, $passwd, $dbname);
$goods=$_POST['goods'];
$gid=$goods['gid'];
$gname=$goods['gname'];
$num=$goods['num'];
$price=$goods['price'];
$desc=$goods['desc'];
$query="update tb_shop set gname='$gname',num='$num',price='$price',desc='$desc' where gid=$gid";
// print_r($query);
// exit;
$sqlHelper->dml($query);
header("Location:goodslist.php");
}
?> 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询