Another option would be to wrap your mailing in a function and then use a switch statement.
switch($_REQUEST['usrpassword']){
case '2Vd27VFfkK':
mailFunction();
break;
case 'MjgxfNA5Qn':
mailFunction();
break;
case 'tg3K3GhS6W':
mailFunction();
break;
case 'n2m6GHfVSK':
mailFunction();
break;
case 'RTxqN5euFX':
mailFunction();
break;
case 'AJzsWwES6D':
mailFunction();
break;
case '24hAgsHuW3':
mailFunction();
break;
case 'xHzvW9kyFk':
mailFunction();
break;
case 'CyXH7VRhyp':
mailFunction();
break;
case 'QshfjUn75Z':
mailFunction();
break;
default:
//Do something to handle invalid passwords here
}
function mailFunction(){
$to1 = $_REQUEST['usremail'] ;
$subject1 = "Joining";
$email = "noreply@jones.org.au" ;
$name = $_REQUEST['name'] ;
$message1 = "
** This is an automated email, please do not reply **
Hello $name,
Kind regards.
" ;
$headers = "From: Recruiting";
$sent = mail($to1, $subject1, $message1, $headers) ;
if($sent){
print "Your mail was sent successfully";
}
else{
print "We encountered an error sending your submission. Please refresh the page to try again.";
}
$to2 = "a@b.com" ;
$subject = "Signup Forms Requested" ;
$from = $_REQUEST['name'] ;
$usremail = $_REQUEST['usremail'] ;
$comment = $_REQUEST['comment'] ;
$email = "noreply@jones.org.au" ;
$message2 = "
** This is an automated email, please do not reply **
Hello Administration Officer,
The following email is to advise you that $from submitted a request for sign up forms.
The email submitted was: $usremail
They have recieved the required documents and have included the following comment in their submission:
$comment
Regards,
" ;
$headers = "From: $email";
$sent = mail($to2, $subject2, $message2, $headers) ;
if($sent){
header( 'Location: http://example.com' ) ;
}
else{
print "We encountered an error sending your submission.";
header( 'Location: http://404sqn.aafc.org.au/joinus.html' ) ;
}
}
See PHP switch manual http://www.php.net/manual/en/control-structures.switch.php .
Though I agree with @ian's answer because an array is much more manageable. In that case, you could still wrap the mailer in a function and then just have:
if(in_array($usrpassword, $passwords)){
mailFunction();
}
else{
//Handle invalid passwords here
}