I am trying to create a form that confirms the user has entered one of the allowed email addresses then redirects the user to the page "NewPost.php"; otherwise (if the user has not entered one of the allowed email addresses), they are stuck on this page. Currently, I can get the entree passed to the next page if I change
<form action="Verify.php">
to
<form action="NewPost.php">
but this disregards the conditional. The form is as follows:
<form action="Verify.php" method="post" name="VerifyEmail" id="VerifyEmail">
<p>Please enter your student email address</p>
<p> <input type="text" name="Email" size="40" maxlength="40" required/></p>
<p><input type="submit" name="Post" value="Post"/></p>
</form>
And the PHP; the $allowed variable is the array of schools whose .edu email addresses should meet the conditional to allow the user entering their email address redirect to NewPost.php
<?php
$Email = trim($_POST['Email']);
$allowed = array ('columbia.edu', 'nyu.edu', 'fitnyc.edu', 'pratt.edu', 'newschool.edu', 'stjohns.edu', 'cooper.edu', 'manhattan.edu', 'pace.edu', 'bard.edu', 'berkeleycollege.edu', 'qc.cuny.edu');
$split = explode($Email, "@");
$name = $split['0'];
$school = $split['1'];
if ($school == $allowed) {
header('Location: /NewPost.php');
}
else{echo "<p>Sorry your school is not supported yet</p>";}
?>
To clarify, I want the visit entering their email address to be redirected to NewPost.php only if their email address is within the $allowed array, otherwise they're stuck on the current page (Verify.php). If anyone wants to try it themselves, the address is here
Thanks!