我有以下文件。出于某种原因,我的JavaScript(PHP '回声' 标签内)不工作:为什么我的Javascript不能使用PHP文件?
HTML(的index.php):
<form action="submit.php" method="post">
<div id="edit-box">
<INPUT type="submit" name="save-text" id="save-text" value="Save">
<textarea id="editor" name="editor">
<?php echo $content; ?>
</textarea>
</div>
</form>
PHP(submit.php):
<?php
include('connect-db.php');
$submit_date = date("Ymd");
$content = mysql_real_escape_string(htmlspecialchars($_POST['editor']));
$ip_address = getRealIPAddress();
if ($content != '') {
mysql_query("INSERT source SET submit_date='$submit_date', ip='$ip_address', content='$content'")
or die(mysql_error());
// The following line is not working! I need help here!
echo '<script type="text/javascript"> alert("Your file saved!");</script>';
mysql_close($connection);
}
?>
的“submit.php”没有任何其他PHP或HTML脚本/标签。我知道我正在使用过时的PHP/MySQL API(而不是PDO/MySQLi),但那不是重点。
@Pekka $'$ content = mysql_real_escape_string(htmlspecialchars($ _ POST ['editor']));' – 2013-03-09 21:08:56
@Kolink我站好了。 – 2013-03-09 21:09:34
值'内容'被正确保存,没有问题。但是,JavaScript(在回声标签内),由于原因不起作用。它好像根本没有到达那里! – 2013-03-09 21:09:38