【发布时间】:2017-09-21 14:08:52
【问题描述】:
我创建了一个带有简单图像上传(我以前使用过)和几个字段的表单。我正在尝试从中获取数据以插入到我的 mysql 数据库中,但这并没有按预期工作。从我的角度来看,我看不出有什么问题。
<?php
error_reporting(E_ALL);
ini_set('error_reporting', 1);
require_once('../../includes/connection.inc.php');
if(isset($_POST['submit']))
{
$dir1 = '/xampp/htdocs/manchesterunited/img/teams/';
$file = $dir1 . basename($_FILES['file']['name']);
$name = $_FILES['file']['name'];
$temp = $_FILES['file']['tmp_name'];
move_uploaded_file($temp,$file);
mysqli_query($mysqli, "INSERT INTO league-table VALUES ('','".$_POST['team']."', '0','0','0','0','0','0','0','$name')");
}
?>
<!doctype html>
<html>
<head>
<title>Add team</title>
</head>
<body>
<a>Add Team To League</a>
<form action="add-team.php" method="POST" enctype="multipart/form-data">
<p><label for="file">Please select the team's badge: </label><input type="file" name="file"/></p>
<p><label for="team">Please enter the team:</label><input type="text" name="team"/></p>
<p><input type="submit" name="submit" value="Add"/></p>
</form>
<?php
if(isset($_POST['submit']))
{
echo "<br />Team has been added.";
}
?>
</body>
</html>
【问题讨论】: