我试图通过textarea发布文本,但我有一个问题,我的问题是textarea在弹出窗口内,当我提交表单获取空字符串时,因此我不能只插入textarea值,其他输入外面的弹出窗口没有问题。
HTML:
<form action="index.php" method="post">
<!-- here are some input texts -->
<input type="text">.........
<!-- but here is a button, when click it show this popup which is written below -->
<input type="button" onclick="showPopup()">
<!-- popup -->
<div id="overlay"></div>
<div id="popup">
<textarea name="txt"></textarea>
<input id="hidepopup" onclick="hidePopup()" type="button" value="Hide popup">
</div>
<input type="submit" name="submit" value="Submit Form">
</form>
PHP:
if(isset($_POST["submit"])
{
$textarea = $_POST["txt"];
$query = "INSERT INTO table ";
$query .= "(text, other inputss....) VALUES("'$textarea', other inputs...")";
$result = mysql_query($con, $query);
if($result) {
echo $textarea; // here I get empty string :(
}
}
答案 0 :(得分:1)
您没有输入名称&#34;提交&#34;,所以
if(isset($_POST["submit"]) { ... }
你永远不会处于这种状态。
这应该有效:
<input type="submit" name="submit" value="Submit Form">
或
<input type="hidden" name="submit" value="1"> //this goes somewhere in the form