我是Web设计的新手,目前正在尝试将图片或其他文件以及其他一些值从Web地址保存到mysql数据库中。
该代码可以很好地保存文件,但是从Web站点获取的其他值( FinancialYear,AssociationRef,Site和QuestionNo )未保存在数据库中,确实需要您的帮助。 / p>
Mysql database settings and records however no values from web address saved
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <!--fit in device width -->
<link href="css/reset.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
</head>
<?php
global $financial_year, $assessment_ref, $site, $quest_no;
if (isset($_GET['FinancialYear'])) {
$financial_year = $_GET['FinancialYear'];
}
if (isset($_GET['AssessmentRef'])) {
$assessment_ref = $_GET['AssessmentRef'];
}
if (isset($_GET['Site'])) {
$site = $_GET['Site'];
}
if (isset($_GET['QuestNo'])) {
$quest_no = $_GET['QuestNo'];
}
$quest_ref=$financial_year . $assessment_ref . $quest_no;
?>
<body>
<form action="file-upload.php" method="POST" enctype="multipart/form-data">
<input type="file" name="file">
<input type="submit" name="submit" value="Upload">
<p><I>Max 16MB per File</I></p>
</form>
<?php
if(isset($_POST['submit'])){
require_once './php-includes/connect.inc.php';
$fileName=mysqli_real_escape_string($db,$_FILES["file"]["name"]);
$fileData=mysqli_real_escape_string($db,file_get_contents($_FILES["file"]["tmp_name"]));
$fileType=mysqli_real_escape_string($db, $_FILES["file"]["type"]);
mysqli_query($db, "INSERT INTO `files` VALUES('$financial_year', '$assessment_ref','$quest_no','$quest_ref','$site','$fileName','$fileType','$fileData',NOW(),'')");
}
?>
</body>
</html>