我正在尝试管理面板工作。我下载了这个示例管理面板设计: http: //medialoot.com/item/html5-admin-template/
HTML结构: http: //pastebin.ubuntu.com/5940949/
我试过PHP代码,
<?php
if(isset($_GET['submit'])){
if($_FILES["carImage"]["error"] > 0){
echo '<script type="text/javascript">alert('."File not upload" . $_FILES["carImage"]["error"].');</script>';
}else{
if(!is_dir("../inc/imj/cars")){
mkdir("../inc/imj/cars");
}
$carImage_ = "../inc/imj/cars".$_FILES["carImage"]["name"];
move_uploaded_file($_FILES["carImage"]["tmp_name"],$carImage_);
mysql_query("
INSERT INTO contents ('indexId','catId','carModelName','carCash','carImage','carAlt','carTitle','carKMH','carWeight','carWheelInch','carColur','info')
VALUES (NULL,'".$_GET['catId']."','".$_GET['carModelName']."','".$_GET['carCash']."','".$carImage_."','".$_GET['carAlt']."','".$_GET['carTitle']."','".$_GET['carKMH']."','".$_GET['carWeight']."','".$_GET['carWheelInch']."','".$_GET['carColur']."','".$_GET['info']."')
");
}
}
?>
我尝试了替代查询代码,
mysql_query("
INSERT INTO contents ('indexId','catId','carModelName','carCash','carImage','carAlt','carTitle','carKMH','carWeight','carWheelInch','carColur','info')
VALUES (NULL,".$_GET['catId'].",".$_GET['carModelName'].",".$_GET['carCash'].",".$carImage_.",".$_GET['carAlt'].",".$_GET['carTitle'].",".$_GET['carKMH'].",".$_GET['carWeight'].",".$_GET['carWheelInch'].",".$_GET['carColur'].",".$_GET['info'].")
");
我猜文件没有上传。所以不工作。
因为错误;
注意:未定义的索引:carImage in ..
注意:未定义的索引:bilgi in ..
注意:TABLE contents.indexId 是主键和自动增量。
我们怎么解决?
感谢您的关注。
更新
图片上传问题是;
<?php
$catId = isset($_GET['catId']) ? $_GET['catId'] : "";
$carModelName = isset($_GET['carModelName']) ? $_GET['carModelName'] : "";
$carCash = isset($_GET['carCash']) ? $_GET['carCash'] : "";
$carAlt = isset($_GET['carAlt']) ? $_GET['carAlt'] : "";
$carTitle = isset($_GET['carTitle']) ? $_GET['carTitle'] : "";
$carKMH = isset($_GET['carKMH']) ? $_GET['carKMH'] : "";
$carWeight = isset($_GET['carWeight']) ? $_GET['carWeight'] : "";
$carWheelInch = isset($_GET['carWheelInch']) ? $_GET['carWheelInch'] : "";
$carColur = isset($_GET['carColur']) ? $_GET['carColur'] : "";
$info = isset($_GET['info']) ? $_GET['info'] : "";
if(isset($_GET['submit'])){
if($_FILES["carImage"]["error"] > 0){
echo '<script type="text/javascript">alert('."File not upload" . $_FILES["carImage"]["error"].');</script>';
}else{
$carUrl_ = "../inc/imj/urun";
if(!is_dir($carUrl_)){mkdir($carUrl_);}
$carImage_ = $carUrl_.$_FILES["carImage"]["name"];
$carUrlName = $_FILES["carImage"]["name"];
move_uploaded_file($_FILES["carImage"]["tmp_name"],$carImage_);
mysql_query("
INSERT INTO contents ('indexId','catId','carModelName','carCash','carImage','carAlt','carTitle','carKMH','carWeight','carWheelInch','carColur','info')
VALUES (".$catId.",".$_GET['carModelName'].",".$_GET['carCash'].",".$carUrlName.",".$carAlt.",".$carTitle.",".$carKMH.",".$carWeight.",".$carWheelInch.",".$carColur.",".$info.")
");
}
}
?>
更新 2
<?php
$catId = isset($_GET['catId']) ? $_GET['catId'] : "";
$carModelName = isset($_GET['carModelName']) ? $_GET['carModelName'] : "";
$carCash = isset($_GET['carCash']) ? $_GET['carCash'] : "";
$carAlt = isset($_GET['carAlt']) ? $_GET['carAlt'] : "";
$carTitle = isset($_GET['carTitle']) ? $_GET['carTitle'] : "";
$carKMH = isset($_GET['carKMH']) ? $_GET['carKMH'] : "";
$carWeight = isset($_GET['carWeight']) ? $_GET['carWeight'] : "";
$carWheelInch = isset($_GET['carWheelInch']) ? $_GET['carWheelInch'] : "";
$carColur = isset($_GET['carColur']) ? $_GET['carColur'] : "";
$info = isset($_GET['info']) ? $_GET['info'] : "";
if(isset($_GET['submit'])){
mysql_query("
INSERT INTO contents ('indexId','catId','carModelName','carCash','carImage','carAlt','carTitle','carKMH','carWeight','carWheelInch','carColur','info')
VALUES (".$catId.",".$_GET['carModelName'].",".$_GET['carCash'].",tryImg.png,".$carAlt.",".$carTitle.",".$carKMH.",".$carWeight.",".$carWheelInch.",".$carColur.",".$info.")
");
}
?>