【发布时间】:2018-03-29 21:26:35
【问题描述】:
我已经检查了我的代码几次,它似乎无法正常工作,因为当 PHP 运行时它只是在浏览器控制台中显示以下错误:
未捕获的 SyntaxError:意外的标识符。
我不确定这只是一个简单的问题还是还有更多问题。
<div class="alert alert-success" role="alert"><h4 id="Txt"> Now In Development</h4></div>
<form method="POST" action="#goHere">
<input type="email" name="email" placeholder="Enter Email For Updates">
<input type="submit" name="submit">
</form>
if(isset($_POST['submit'])) {
$email = htmlentities(strip_tags($_POST['email']));
$logname = 'list/email.txt';
$logcontents = file_get_contents($logname);
$searchfor = $email;
// the following line prevents the browser from parsing this as HTML.
//header('Content-Type: text/plain');
// get the file contents, assuming the file to be readable (and exist)
$contents = file_get_contents($logname);
// escape special characters in the query
$pattern = preg_quote($searchfor, '/');
// finalise the regular expression, matching the whole line
$pattern = "/^.*$pattern.*\$/m";
// search, and store all matching occurences in $matches
$filecontents = $email."\r\n";
$fileopen = fopen($logname,'a+');
$filewrite = fwrite($fileopen,$filecontents);
$fileclose = fclose($fileopen);
if($email == NULL) {
echo '<Script> document.getElementById("Txt").innerHTML = "<div class="alert alert-danger" role="alert">"You entered Nothing</div>"; </script>';
} elseif(preg_match_all($pattern, $contents, $matches)){
echo '<Script> document.getElementById("Txt").innerHTML = "<div class="alert alert-success" role="alert">Email was already added</div>"; </script>';
} else {
if(!$fileopen or !$filewrite or !$fileclose) {
echo '<Script> document.getElementById("Txt").innerHTML = "Thankyou"; </script>';
} else {
echo '<Script> document.getElementById("Txt").innerHTML = "<div class="alert alert-success" role="alert">Email Succefully Added"; </script>';
}
}
}
【问题讨论】:
-
你需要使用
<?php包装php代码 -
我认为没有 包装器....
-
php 包装器在那里我刚刚从我正在处理 php 的项目中取出它工作正常并执行。
-
您能否引用错误,以便我们可以更详细地了解错误..
-
Uncaught SyntaxError: Unexpected identifier i click on the error and it doesn't like the lines php is trying to execute";
标签: javascript php css html bootstrap-4