My code is as follows:
//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();
}
If there are any input validations from the registration page, the user will be directed back to the registration page. What I want to do is when they are redirected back, $_SESSION[‘ERROR’] will = True. When and only when that is = True, do I want a popup box to display a error message. I the code for the popup message. I just can’t figure out how to get it to load only on the if $_SESSION[‘ERROR’] == ‘True’
<script language="javascript">
alert('<?= $s ?>')
</script>
That code will display a message with a php variable. I need help getting the message to display only when the $_SESSION[‘ERROR’] equals ‘True’
Thank you!
Somewhere in your register page:
Of course, it won’t work if JS is disabled. You could add in a noscript tag as well and at least display the error message in the same fashion.