Hi All,
We are currently using a form to handle teacher’s computer service requests that get sent to our support email.
The problem we have is the user sometimes misspells her email address and also we haven’t figured out a way to add attachments. (Screenshots of alert messages, etc.)
What I’d like to do now is have a few of the form fields simply become the subject of an email that opens in the teachers gmail (Google Apps for Education) account. (All our teachers have Google Apps accounts and use the gmail client so that will not be an issue.)
Similar to how mailto works in HTML except I’d need the building CODE, ROOM number and teacher NAME in the subject line.
Essentially I want the user to be able to edit their own email service request but have the form to ensure CODE, ROOM and NAME are in the subject line.
I admit I’m not good at this. If you can walk me through step by step or show me some example code, that would be great!
I have attached the HTML and PHP of our current service request form for reference.
HTML…index.html
Service Request Form Computer Service Request FormBuilding:
Choose your building...
Kinnikinnick School (KS)
Ledgewood School (LW)
Roscoe Middle School (RMS)
Stone Creek School (SC)
District Office (DO)
Room: | |
Name: | |
Email: |
Request: (One issue per Request, please.)
PHP…send.php
<?php $code = check_input($_POST['code'],"Please go BACK and choose your building!"); $room = check_input($_POST['room'],"Please go BACK and enter your room #!"); $name = check_input($_POST['name'],"Please go BACK and enter your name!"); $email = check_input($_POST['email']); $date = date('Ymd/his', time()); if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email)) { die("Please go BACK and enter a valid email address!"); } $request = check_input($_POST['request'],"Please go BACK and describe your problem!"); ?> <?php $header = "From: $email\r\nReply-To: $email\r\n"; $recipient = "[email protected]"; $subject = "$code-$room $name - $date"; $message = "$code-$room $name - $request"; mail($recipient, $subject, $message, $header); ?> Your message was successfully sent!You will be contacted soon. <?php function check_input($data, $empty='') { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); if ($empty && strlen($data) == 0) { die($empty); } return $data; } ?>