[英]PHP page does not load when I try to show an error message
我试图在表单上显示重复错误,但此功能使页面崩溃并且页面无法加载。 如何为此配置文件php.ini ?
这是我试图在表单页面上显示错误消息的功能:
public function getError($error) {
if(!in_array($error, $this->errorArray)) {
$error = "";
}
return "<span class='errorMessage'>$error</span>";
}
这是我试图用来获取数组中的错误的函数:
private function validateEmails($em) {
$checkEmailQuery = mysqli_query($this->con,"SELECT email FROM member_forms WHERE email='$em'");
if(mysqli_num_rows($checkEmailQuery) != 0) {
array_push($this->errorArray, Strings::$emExists);
return;
}
}
这些函数对数据库进行双重检查,如果发生错误, <?php echo $account->getError(Strings::$emExists); ?>
<?php echo $account->getError(Strings::$emExists); ?>
应该显示它,但它没有并且页面不会加载。
当错误发生时,它会一直持续到错误为止,但它不会呈现任何内容并且 HTML 页面的正文变为空
<div class="form-group" style="padding-left: 0px;">
<p>
<?php echo $account->getError(Strings::$fnCharacters); ?>
<div class="col-md-3 indent-small">
<div class="form-group internal">
<input class="form-control" id="firstName"
name="firstName" type="text"
placeholder="First Name"
style="width: 180%;/*! padding-right: ; */margin: 0px 0px 0px 12px;"
value="<?php getInputValue('firstName')?>" required>
</div>
</div>
<div class="col-md-3 indent-small"
style="margin-left: 15px;width: 25%;">
<div class="form-group internal">
<input class="form-control" id="lastName"
name="lastName" type="text" placeholder="Last Name"
style="width: 188%;/*! padding-left: 33px; */margin-left: 56px;"
value="<?php getInputValue('lastName')?>" required>
</div>
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-2 col-md-offset-2" for="email"
style="margin-left: 0;width: 28%;/*! float: left; */">E-mail
Address</label>
<div class="col-md-6">
<div class="form-group">
<div class="col-md-11">
<p>
<?php echo $account->getError(Strings::$emExists); ?>
<input class="form-control" id="email" name="email"
type="email" placeholder="Your E-mail..."
style="width: 156%;"
required>
</p>
</div>
</div>
</div>
</div>
我很确定这段代码应该修复这个错误:
if (isset($_POST['Update'])) {
/* a bunch of code to insert into the DB */
// if inserted echo the following messges
if ($r) {
echo "<script> alert('Saved')</script>";
}else{
echo "<b>Oops! we have an issu </b>";
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.