我有以下文件。由于某种原因,我的 JavaScript(在 PHP 'echo' 标签内)不起作用:
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(提交.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),但这不是重点。