0
我的代碼如下所示的JavaScript彈出一個對話框:的if語句
//Input Validations
$result = mysql_query("SELECT * FROM members WHERE `email` = '$insp_email' LIMIT 1");
$exist = mysql_fetch_row($result);
if ($exist !==false) {
$errmsg_arr[] = 'That Email is already registered.';
$errflag = true;
}
$result = mysql_query("SELECT * FROM members WHERE `login` = '$user_name' LIMIT 1");
$exist = mysql_fetch_row($result);
if ($exist !==false) {
$errmsg_arr[] = 'That Username is already registered.';
$errflag = true;
}
//If there are input validations, redirect back to the registration form
if($errflag) {
$_SESSION['ERRMSG_ARR'] = $errmsg_arr;
$_SESSION['ERROR'] = 'Yes';
session_write_close();
header("location: accountinfo.php");
exit();
}
如果沒有在註冊頁面上的任何輸入驗證,用戶將被引導回註冊頁面。我想要做的是當他們被重定向回來時,$ _SESSION ['ERROR'] will = True。當且僅當= is True時,我是否需要一個彈出框來顯示錯誤消息。我彈出消息的代碼。我只是無法弄清楚如何得到它加載只在當$ _SESSION [「錯誤」] ==「真」
<script language="javascript">
alert('<?= $s ?>')
</script>
該代碼將顯示一個PHP變量的消息。只有當$ _SESSION ['ERROR']等於'True'時,我需要幫助才能顯示消息。
謝謝!
'警報()'表單錯誤框是討厭的地獄。 – ThiefMaster