php - 使用 mysqli 方法和文件函数将 html 表单资源存储到 mySQL 中时遇到问题
问题描述
在表单之前运行的 PHP
<?php
error_reporting(E_ALL);
ini_set('display_errors',1);
include 'config.php';
include 'pageblocks.php';
include 'functions.php';
if ( isset( $_POST ) && ! empty( $_FILES ) ) {
echo upload_file();
echo '1';
$stmt = $conn->prepare("INSERT INTO art_content (headline, content_type, postdate, title,
content, index_thumb) VALUES (?,?,?,?,?,?)");
echo '2';
$stmt->bind_param('ssssss', $_POST['headline'],
$_POST['content_type'], $_POST['postdate'], $_POST['title'], $_POST['content'],
$_POST['file']);
echo '3';
$stmt->execute();
echo '4';
$conn->close();
unset($_POST);
}
metablock('content upload page');
headerblock('');
?>
我试图在现场实施的表格
<form method ="post" action="" enctype="multipart/form-data">
<label for="headline"><strong>Choose Index Headline</strong></label><br><br>
<select name="headline">
<option value="addition to gallery">addition to gallery</option>
<option value="new patron content">new patron content</option>
<option value="new youtube video">new youtube video</option>
<option value="new addition to articles">new addition to articles</option>
</select><br><br>
<label for="content_type"><strong>Choose content type:</strong></label><br><br>
<select name="content_type">
<option value="digital photograph">digital photograph</option>
<option value="digital painting">digital painting</option>
<option value="traditional painting">traditional painting</option>
<option value="twitch branding">twitch branding</option>
<option value="article">article</option>
</select><br><br>
<label><strong>post date</strong></label><br><br>
<input name="postdate" type="text"><br><br>
<label><strong>title</strong></label><br><br>
<input name="title" type="text"><br><br>
<label><strong>text content</strong></label><br><br>
<textarea name="content" type="text"></textarea><br><br>
<input type="file" name="file">
<input type="submit" value="Upload">
</form>
我的上传文件功能工作正常,但 MySQL 数据似乎没有进入服务器。我不知道该怎么做,正在考虑尝试 PDO 方法,因为它看起来不那么令人困惑,但放弃 mysqli 方法来连接感觉不好
解决方案
推荐阅读
- c# - unity c# 马里奥游戏
- python - 绘图上的双标记 Matlotlib
- javascript - 使用 html 按钮而不是使用 Mapbox GL JS 的链接来切换 GeoJSON 图层
- c++ - `shared_ptr`s 如何实现协方差?
- elixir - elixir - Ecto 变更集成功和失败代码不再运行
- python - 如何在 URL 中使用页码抓取多个页面
- python - 改变numpy的基础
- postgresql - 由于空白字符串被视为不存在的数据,因此无法从 pg_dump 恢复数据
- java - JavaFX:如何将 TitledPane 中的“下拉箭头”移动到右侧
- html - 在绝对 div 内水平居中表情符号