我有一个表单中的文本区域。该表单在提交时会将一些信息插入到数据库中。即使“newsText”是长文本,我也只能插入短字符串。我将用确切的字符数量更新这个问题。
表格:
<form id="newsForm" action="<?php echo $uploadHandler ?>" enctype="multipart/form-data" method="post">
<div class="managementNewsTitle">
Title<br />
<input id="inputNewsTitle" name="inputNewsTitle" type="text"></input>
</div>
<div class="managementNewsTitle">
Image<br />
<input id="inputNewsFile" type="file" name="file" onchange="document.getElementById('inputNewsFilename').value = value;"><br />
Name<br />
<input id="inputNewsFilename" type="text"></input>
</div>
<div class="managementNewsTitle">
Text<br />
<textarea id="inputNewsText" name="inputNewsText"></textarea>
</div>
<input type="hidden" name="givenFileName" id="givenFileName" value="">
<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_file_size; ?>">
<input type="hidden" name="newsSubmitValue" id="submitValue" value="no">
<input type="button" id="newsSubmitButton" onclick="newsSubmit()" name="submitButton" value="Save"></input>
</form>
插入:
if($_POST['newsSubmitValue'] === "yes") {
$newsTitle = $_POST['inputNewsTitle'];
$newsText = $_POST['inputNewsText'];
$newsImageURL = $_POST['givenFileName'];
mysql_query("INSERT INTO cs_news VALUES (DEFAULT, CURRENT_TIMESTAMP, '".$newsTitle."', '".$newsText."', 'Images/".$newsImageURL."')");
}