adamlonsdale
Dec 16th, 2009, 04:32 AM
I have a PHP form, that asks for peoples details to apply for a free transport card. Basically I get an email that looks as though it is sent from them, and then have to reply to it asking for a photo. Here is my code:
On the form page:
<form method="POST" action="hidden">
<tr>
<td class="size">Title</td>
<td width="326" class="stuff"><input type="text" name="title" size="19" /></td>
</tr>
<tr>
<td class="size">First Name</td>
<td class="stuff"><input type="text" name="first" size="19" /></td>
</tr>
<tr>
<td class="size">Last Name</td>
<td class="stuff"><input type="text" name="last" size="19" /></td>
</tr>
<tr>
<td class="size"> </td>
<td class="stuff"> </td>
</tr>
<tr>
<td class="size">Date of Birth</td>
<td class="stuff"><input name="day" type="las" size="2" maxlength="2" />
/
<input name="month" type="text" size="2" maxlength="2" />
/
<input name="year" type="text" size="4" maxlength="4" /></td>
</tr>
<tr>
<td class="size"> </td>
<td class="stuff"> </td>
</tr>
<tr>
<td class="size">Address</td>
<td class="stuff"><textarea rows="5" name="address" cols="30"></textarea></td>
</tr>
<tr>
<td class="size">Telephone</td>
<td class="stuff"><input type="text" name="tel" size="19" /></td>
</tr>
<tr>
<td class="size">Email</td>
<td class="stuff"><input type="text" name="email" size="19" /></td>
</tr>
<tr>
<td class="size"> </td>
<td class="stuff"> </td>
</tr>
<tr>
<td class="size">School</td>
<td class="stuff"><select size="1" name="drop_down">
<option selected="selected"></option>
<option>Beverley High School</option>
<option>Beverley Youth Centre</option>
<option>Bishop Burton College</option>
<option>Bridlington School Sports College</option>
<option>Bridlington Youth Centre</option>
<option>Cottingham High School</option>
<option>Driffield School</option>
<option>Driffield Youth Centre</option>
<option>East Riding College (Beverley Campus)</option>
<option>East Riding College (Bridlington Campus)</option>
<option>Goole Youth Centre</option>
<option>Headlands School and Community Science College</option>
<option>Hessle High Lower School</option>
<option>Hessle High Upper School</option>
<option>Hull College</option>
<option>Hornsea School and Language College</option>
<option>Hornsea Youth Centre</option>
<option>Howden School</option>
<option>Howden Youth Centre</option>
<option>John Leggott College</option>
<option>Longcroft School</option>
<option>Market Weighton Youth Centre</option>
<option>Pocklington School</option>
<option>Pocklington Youth Centre</option>
<option>Old Goole Youth Centre</option>
<option>Snaith Youth Centre</option>
<option>South Holderness Technology College</option>
<option>South Holderness Youth Centre
<option>South Hunsley School</option>
<option>South Hunsley Youth Centre</option>
<option>The Market Weighton School</option>
<option>The Snaith School</option>
<option>Wilberforce College</option>
<option>Withernsea High School</option>
<option>Withernsea Youth Centre</option>
<option>Woldgate College</option>
<option>Wolfreton Lower School</option>
<option>Wolfreton Youth Centre</option>
<option>Wyke College</option>
<option>Other</option>
</select></td>
</tr>
<tr>
<td class="size"><p class="size">Other</p></td>
<td class="stuff"><input type="text" name="other" size="30" /></td>
</tr>
<tr>
<td class="size"> </td>
<td class="stuff"> </td>
</tr>
<tr>
<td class="size"><p class="size">Where did you hear about the scheme?</p></td>
<td class="stuff"><input type="text" name="where" size="30" id="where" /></td>
</tr>
<tr>
<td class="size">Do you have any further comments?</td>
<td class="stuff"><textarea rows="5" name="comments" cols="30" id="comments"></textarea></td>
</tr>
<tr>
<td class="size"> </td>
<td class="stuff"> </td>
</tr>
<tr>
<td class="size"><p class="size">Data Protection</p>
<p><em class="xxsmall"><b></b>Due to the nature of the pilot, you must agree to allow the East Riding of Yorkshire Council to access your bus card data.</em></p></td>
<td class="stuff"><input type="radio" value="yes" name="radio" />
Yes<br />
<input type="radio" value="no" name="radio" />
No</td>
</tr>
<tr>
<td colspan="2"><p align="center">
<input name="submit" type="submit" class="SubmitButton" align="middle" value="Submit" />
</p></td>
</tr>
</table></td></form>
And then on the processing page:
<?php
if(isset($_POST['submit'])) {
$to = "my email address";
$subject = "Pilot Card Application";
$title = $_POST['title'];
$first = $_POST['first'];
$last = $_POST['last'];
$day = $_POST['day'];
$month = $_POST['month'];
$year = $_POST['year'];
$address = $_POST['address'];
$tel = $_POST['tel'];
$email = $_POST['email'];
$option = $_POST['radio'];
$dropdown = $_POST['drop_down'];
$other = $_POST['other'];
$header = "From: $email <$email>";
$where = $_POST['where'];
$comments = $_POST['comments'];
$body = "Transport Pilot Application from $title $first $last\n\n Title: $title\n First Name: $first\n Last Name: $last\n\n Date of Birth: $day / $month / $year\n\n Address:\n$address\n\n Telephone Number: $tel\n Email: $email\n\n School: $dropdown\n Other: $other\n\n Data Protection: $option\n\n $first heard about the scheme from: $where\n\n Other Comments: $comments";
echo
"<font=verdana><p align=center><b>Thank you for applying for the East Riding Youth Assembly's transport card. <br /> Somebody will get back to you within a few days.</p><br /><p align=center>If you have any further enquiries, please contact my managers email address or call his phone numbe</p></b></font>";
mail($to, $subject, $body, $header);
} else {
echo "blarg!";
}
?>
Basically, how would I modify this code to add:
A form where users can upload a picture
A part to the mailer form that would send the image as an attachment
Facilities to limit the size and file type.
Adam.
On the form page:
<form method="POST" action="hidden">
<tr>
<td class="size">Title</td>
<td width="326" class="stuff"><input type="text" name="title" size="19" /></td>
</tr>
<tr>
<td class="size">First Name</td>
<td class="stuff"><input type="text" name="first" size="19" /></td>
</tr>
<tr>
<td class="size">Last Name</td>
<td class="stuff"><input type="text" name="last" size="19" /></td>
</tr>
<tr>
<td class="size"> </td>
<td class="stuff"> </td>
</tr>
<tr>
<td class="size">Date of Birth</td>
<td class="stuff"><input name="day" type="las" size="2" maxlength="2" />
/
<input name="month" type="text" size="2" maxlength="2" />
/
<input name="year" type="text" size="4" maxlength="4" /></td>
</tr>
<tr>
<td class="size"> </td>
<td class="stuff"> </td>
</tr>
<tr>
<td class="size">Address</td>
<td class="stuff"><textarea rows="5" name="address" cols="30"></textarea></td>
</tr>
<tr>
<td class="size">Telephone</td>
<td class="stuff"><input type="text" name="tel" size="19" /></td>
</tr>
<tr>
<td class="size">Email</td>
<td class="stuff"><input type="text" name="email" size="19" /></td>
</tr>
<tr>
<td class="size"> </td>
<td class="stuff"> </td>
</tr>
<tr>
<td class="size">School</td>
<td class="stuff"><select size="1" name="drop_down">
<option selected="selected"></option>
<option>Beverley High School</option>
<option>Beverley Youth Centre</option>
<option>Bishop Burton College</option>
<option>Bridlington School Sports College</option>
<option>Bridlington Youth Centre</option>
<option>Cottingham High School</option>
<option>Driffield School</option>
<option>Driffield Youth Centre</option>
<option>East Riding College (Beverley Campus)</option>
<option>East Riding College (Bridlington Campus)</option>
<option>Goole Youth Centre</option>
<option>Headlands School and Community Science College</option>
<option>Hessle High Lower School</option>
<option>Hessle High Upper School</option>
<option>Hull College</option>
<option>Hornsea School and Language College</option>
<option>Hornsea Youth Centre</option>
<option>Howden School</option>
<option>Howden Youth Centre</option>
<option>John Leggott College</option>
<option>Longcroft School</option>
<option>Market Weighton Youth Centre</option>
<option>Pocklington School</option>
<option>Pocklington Youth Centre</option>
<option>Old Goole Youth Centre</option>
<option>Snaith Youth Centre</option>
<option>South Holderness Technology College</option>
<option>South Holderness Youth Centre
<option>South Hunsley School</option>
<option>South Hunsley Youth Centre</option>
<option>The Market Weighton School</option>
<option>The Snaith School</option>
<option>Wilberforce College</option>
<option>Withernsea High School</option>
<option>Withernsea Youth Centre</option>
<option>Woldgate College</option>
<option>Wolfreton Lower School</option>
<option>Wolfreton Youth Centre</option>
<option>Wyke College</option>
<option>Other</option>
</select></td>
</tr>
<tr>
<td class="size"><p class="size">Other</p></td>
<td class="stuff"><input type="text" name="other" size="30" /></td>
</tr>
<tr>
<td class="size"> </td>
<td class="stuff"> </td>
</tr>
<tr>
<td class="size"><p class="size">Where did you hear about the scheme?</p></td>
<td class="stuff"><input type="text" name="where" size="30" id="where" /></td>
</tr>
<tr>
<td class="size">Do you have any further comments?</td>
<td class="stuff"><textarea rows="5" name="comments" cols="30" id="comments"></textarea></td>
</tr>
<tr>
<td class="size"> </td>
<td class="stuff"> </td>
</tr>
<tr>
<td class="size"><p class="size">Data Protection</p>
<p><em class="xxsmall"><b></b>Due to the nature of the pilot, you must agree to allow the East Riding of Yorkshire Council to access your bus card data.</em></p></td>
<td class="stuff"><input type="radio" value="yes" name="radio" />
Yes<br />
<input type="radio" value="no" name="radio" />
No</td>
</tr>
<tr>
<td colspan="2"><p align="center">
<input name="submit" type="submit" class="SubmitButton" align="middle" value="Submit" />
</p></td>
</tr>
</table></td></form>
And then on the processing page:
<?php
if(isset($_POST['submit'])) {
$to = "my email address";
$subject = "Pilot Card Application";
$title = $_POST['title'];
$first = $_POST['first'];
$last = $_POST['last'];
$day = $_POST['day'];
$month = $_POST['month'];
$year = $_POST['year'];
$address = $_POST['address'];
$tel = $_POST['tel'];
$email = $_POST['email'];
$option = $_POST['radio'];
$dropdown = $_POST['drop_down'];
$other = $_POST['other'];
$header = "From: $email <$email>";
$where = $_POST['where'];
$comments = $_POST['comments'];
$body = "Transport Pilot Application from $title $first $last\n\n Title: $title\n First Name: $first\n Last Name: $last\n\n Date of Birth: $day / $month / $year\n\n Address:\n$address\n\n Telephone Number: $tel\n Email: $email\n\n School: $dropdown\n Other: $other\n\n Data Protection: $option\n\n $first heard about the scheme from: $where\n\n Other Comments: $comments";
echo
"<font=verdana><p align=center><b>Thank you for applying for the East Riding Youth Assembly's transport card. <br /> Somebody will get back to you within a few days.</p><br /><p align=center>If you have any further enquiries, please contact my managers email address or call his phone numbe</p></b></font>";
mail($to, $subject, $body, $header);
} else {
echo "blarg!";
}
?>
Basically, how would I modify this code to add:
A form where users can upload a picture
A part to the mailer form that would send the image as an attachment
Facilities to limit the size and file type.
Adam.