다음 파일이 있습니다. 어떤 이유로 (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 대신)를 사용하고 있다는 것을 이해하고 있지만, 요점은 바로 그 점입니다. 코드
<?php
include('connect-db.php');
$submit_date = date("Ymd");
$content = mysql_real_escape_string(htmlspecialchars($_POST['editor']));
$ip_address = getRealIPAddress();
$content = $_POST["editor"];
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);
}
?>
@Pekka 웃'$ 콘텐츠 = mysql_real_escape_string를 (반드시 htmlspecialchars ($ _ POST [ '에디터']));' –
@Kolink 내가 그렇군요. –
'content'값이 올바르게 저장되고 있으면 문제가 없습니다. 그러나 Javascript (에코 태그 내부)는 작동하지 않습니다. 마치 거기에 도달하지 못하는 것 같습니다! –