<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
$this_file = $_SERVER['PHP_SELF'];
switch ($_GET['id'])
{
# Firstly we find if the person has filled in the form and wants to send
case "postmail":
switch ($_POST['admin_number'])
{
# Depending on which Admission Number they chose, select the appropriate domain
case "4ni00": $domain = "college.com"; break;
case "4ni01": $domain = "college.net"; break;
case "4ni02": $domain = "college.edu"; break;
case "4ni03": $domain = "college.edu"; break;
}
# Gather all the information into handy variables
# Send the message to the admin number @ the selected domain
$to = $_POST['admin_number'] . $_POST['admin_number_2'] . "@" . $domain;
# Set the from e-mail as the sender name,
sendername@college.com $from = "From: \"" .$_POST['sender_name']. "\" <" .$_POST['sender_name']. "@college.com>";
# Store the subject in the subject variable
$subject = $_POST['subject'];
# Store the message in the message variable
$message = $_POST['message'];
# Check to see whether the message sent successfully
if (mail($to,$subject,$message,$from))
{
# If it did, tell the user it was sent and redirect them back to the form
echo "<center><font size=\"1\">";
echo "Your message has been sent to its destination<br>Please wait while you are re-directed to the main page.";
echo "<meta content=\"2; url=" .$_SERVER['PHP_SELF']. "\" http-equiv=\"refresh\">";
echo "</font></center>";
}
else
{
# If it failed, tell the user it failed and redirect them back to the form
echo "<center><font size=\"1\">";
echo "Your message has failed to send to its destination<br>Please wait while you are re-directed to the main page.";
echo "<meta content=\"2; url=" .$_SERVER['PHP_SELF']. "\" http-equiv=\"refresh\">";
echo "</font></center>";
}
break;
# If the user has not already filled in the form, present the form for them
default:
?>
<form name="form1" method="post" action="<?php echo $this_file . "?id=post" ?>">
Adminision Number:
<select name="admin_number">
<option value="4ni00">4NI00</option>
<option value="4ni01">4NI01</option>
<option value="4ni02">4NI02</option>
<option value="4ni03">4NI03</option>
</select>
<input name="admin_number_2" type="text" id="admin_no">
<br>
<br>
Sender Name:
<input name="sender_name" type="text" id="sender_name">
<br>
<br>
Subject:
<input name="subject" type="text" id="subject">
<br>
<br>
Message:<br>
<textarea name="message" cols="45" rows="7" id="message"></textarea>
<br>
<br>
<input type="submit" name="Submit" value="Send Message">
</form>
<?php break; } ?>
</body>
</html>