Hey everyone,
I've got a simple PHP mail form working on the intranet at work but now I want to customize it for our use. Basically it's going to be a form that teachers can fill in when there is a lock-down (drill or otherwise) to inform the necessary people that they are okay.
The script consists of two files - sendeail.php
...and contact.php
So what I need to do is listed below:
- Rather than the user inputting their e-mail address, I need it to always send FROM a specified address (eg. [email protected])
- The 'Your Name' field needs to display in the 'Subject:' header of the resulting e-mail
- Where it says 'All Students Accounted For?' was actually a 'CC:' option but I just need it to list the YES or NO answer in the resulting e-mail
- I also want to add a couple more multi-line text boxes where they can add names of missing students and other staff in the classroom
I think that's about it... I'm sorry but I have NO IDEA where to start! Can somebody help me?
Thanks heaps in advance!
Neil
EDIT: Removed e-mail address
I've got a simple PHP mail form working on the intranet at work but now I want to customize it for our use. Basically it's going to be a form that teachers can fill in when there is a lock-down (drill or otherwise) to inform the necessary people that they are okay.
The script consists of two files - sendeail.php
PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sendemail Script</title>
</head>
<body>
<!-- Required: YOUR email ($myemail). Optional: Enter CC email address ($ccx)
Required: Add the link for the 'next page' (at the bottom) -->
<?php
$myemail = "[email protected]";
$ccx = "";
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
}
if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<h2>Use Back - fill in all fields</h2>\n";
}
echo $badinput;
$todayis = date("l, F j, Y, g:i a") ;
$attn = $attn . "(" . $ccopy . ")" ;
$subject = $attn;
$notes = stripcslashes($notes);
$message = " $todayis [EST] \n
Attention: $attn \n
Message: $notes \n
From: $visitor ($visitormail)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";
$from = "From: $visitormail\r\n";
if (($ccopy == "ccyes") && ($visitormail != ""))
mail($visitormail, $subject, $message, $from);
if ($myemail != "")
mail($myemail, $subject, $message, $from);
if ($ccx != "")
mail($ccx, $subject, $message, $from);
?>
<p align="center">
Date: <?php echo $todayis ?>
<br />
Thank You : <?php echo $visitor ?> ( <?php echo $visitormail ?> )
<br />
Attention: <?php echo $attn ?>
<br />
Message:<br />
<?php $notesout = str_replace("\r", "<br/>", $notes);
echo $notesout; ?>
<br />
<?php echo $ip ?>
<br /><br />
<a href="contact.php"> Next Page </a>
</p>
</body>
</html>
...and contact.php
PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Email Form </title>
</head>
<body>
<form method="post" action="sendeail.php">
<!-- DO NOT change ANY of the php sections -->
<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>
<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />
Your Name: <br />
<input type="text" name="visitor" size="35" />
<br />
Your Email:<br />
<input type="text" name="visitormail" size="35" />
<br /> <br />
All Students Accounted For ? No
<input name="ccopy" type="radio" value="ccno" /> Yes<input checked="checked" name="ccopy" type="radio" value="ccyes" /> <br />
<br />
Attention:<br />
<select name="attn" size="1">
<option value=" Sales n Billing ">Sales n Billing </option>
<option value=" General Support ">General Support </option>
<option value=" Technical Support ">Technical Support </option>
<option value=" Webmaster ">Webmaster </option>
</select>
<br /><br />
Mail Message:
<br />
<textarea name="notes" rows="4" cols="40"></textarea>
<br />
<input type="submit" value="Send Mail" />
<br />
<!-- Free Code at: http://www.ibdhost.com/contact/ -->
</form>
</body>
</html>
So what I need to do is listed below:
- Rather than the user inputting their e-mail address, I need it to always send FROM a specified address (eg. [email protected])
- The 'Your Name' field needs to display in the 'Subject:' header of the resulting e-mail
- Where it says 'All Students Accounted For?' was actually a 'CC:' option but I just need it to list the YES or NO answer in the resulting e-mail
- I also want to add a couple more multi-line text boxes where they can add names of missing students and other staff in the classroom
I think that's about it... I'm sorry but I have NO IDEA where to start! Can somebody help me?
Thanks heaps in advance!
Neil
EDIT: Removed e-mail address
Last edited:







