Hello Everyone,
I have been asked to produce a webform that will take user data (name, email and comments) and a file attachment (specifically a CV) and e-mail it to the recruitment staff in the office. On top of that it must send out a reply e-mail to the user thanking them. It also sends the collected data and cv attachment to the recruiters in a html format.
I created the form in the way that I know, however it is getting a bit complicated now that I have to add this file attach functions. (I did have a file attach working php form, but it does not integrate well with this one, that is my fault I think, hence my post here)
I will post the form I have written without the file attach code so that people can offer opinions as to how to include a file attachment code segment into this form that will actually work. I am pulling my hair out, please help :mad::eek::glare:
A copy of my php code for the form and the html for the form itself follows. These are both contained within one document. Any help to add an attachment function would be appreciated and a cookie will be waiting. 😉
<!-- My PHP Form without attachment function active -->
<?php
$action=$_REQUEST['action'];
if ($action=='sendmessage') {
// Variables List, Booyakasha!.
$fname=$_REQUEST['fname']; //Gets the First Name
$lname=$_REQUEST['lname']; //Gets the Last Name
$email=$_REQUEST['email']; //Gets the Email Address
$mime_type = "text/html"; //Email type, defined.
$activities=$_POST['element_6']; //Salary Dropdown
$activities=$_POST['element_7']; //SkillSet Dropwdown
$comments=stripslashes($_REQUEST['comments']); //Removes the forward and back slashes
$newcomments = wordwrap($comments, 8, "\n", true); // Ok so I added this in to wrap the text in the comments sections
$replyemail=$_POST['email']; //Email a reply to the user, created reply variables
$replysubject= "CV Recieved"; //Reply Subject Line
$replymessage="Thank you for submitting your cv to us, we will process your information and add you to our recruitment files.<br />
If an oppertunity should arise to which we feel you are suited we will contact you immediately.<br /><br />
If you have any questions then please contact the head office on ***** ******.<br />
We would like to thank you for taking the time to submit your CV.<br /><br />"; //Message body
$replyheader = "MIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1\r\n" //Oh the pain
. "From: myemail@mycompany.com\n"
. "Reply-To: myemail@mycompany.com\n";
//It's email Contents time, and here it is
$header = "MIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1\r\n"
. "From: myemail@mycompany.com\n"
. "Reply-To: myemail@mycompany.com\n";
$subject = "Website CV Submission"; //Oh my, a subject line o.O
$email_to = "myemail@mycompany.com\n"; //Thats me by the way
$message = '
<table width="450" border="0" cellspacing="1" cellpadding="40">
<tr>
<td bgcolor="430c0c"><table cellspacing="1" cellpadding="8" border="0" width="400">
<tr>
<td colspan="2"></td>
</tr>
<tr bgcolor="#eeeeee">
<td colspan="2" bgcolor="cd010d" style="font-family:Verdana, Arial; font-size:18px; color:#ffffff;"><strong>CV Submission</strong> </td>
</tr>
<tr bgcolor="#eeeeee">
<td bgcolor="cd010d" style="font-family:Verdana, Arial; font-size:11px; color:#ffffff;"><strong>First Name:</strong></td>
<td bgcolor="9e010d" style="font-family:Verdana, Arial; font-size:11px; color:#ffffff;">'.$fname.'</td>
</tr>
<tr bgcolor="#eeeeee">
<td bgcolor="cd010d" style="font-family:Verdana, Arial; font-size:11px; color:#ffffff;"><strong>Last Name:</strong></td>
<td bgcolor="9e010d" style="font-family:Verdana, Arial; font-size:11px; color:#ffffff;">'.$lname.'</td>
</tr>
<tr bgcolor="#eeeeee">
<td bgcolor="cd010d" style="font-family:Verdana, Arial; font-size:11px; color:#ffffff;"><strong>Email Address:</strong></td>
<td bgcolor="9e010d" style="font-family:Verdana, Arial; font-size:11px; color:#ffffff;">'.$email.'</td>
</tr>
<tr bgcolor="#eeeeee">
<td bgcolor="cd010d" style="font-family:Verdana, Arial; font-size:11px; color:#ffffff;"><strong>Expected Salary:</strong></td>
<td bgcolor="9e010d" style="font-family:Verdana, Arial; font-size:11px; color:#ffffff;">'.$element_6.'</td>
</tr>
<tr bgcolor="#eeeeee">
<td bgcolor="cd010d" style="font-family:Verdana, Arial; font-size:11px; color:#ffffff;"><strong>Skill Set:</strong></td>
<td bgcolor="9e010d" style="font-family:Verdana, Arial; font-size:11px; color:#ffffff;">'.$element_7.'</td>
</tr>
<tr bgcolor="#eeeeee">
<td colspan="2" bgcolor="9e010d" style="font-family:Verdana, Arial; font-size:11px; color:#ffffff;">'.$newcomments.'</td>
</tr>
<tr bgcolor="#eeeeee">
<td colspan="2" bgcolor="9e010d" style="font-family:Verdana, Arial; font-size:11px; color:#ffffff></td>
</tr>
</table>
</td>
</tr>
</table>
'
;
$mail=mail($email_to, $subject ,$message ,$header ) ;
if ($mail==0) {
echo"There was a problem sending the message please try again later!"; //message to be revised.
} else {
$mail=mail ($replyemail, $replysubject, $replymessage, $replyheader );
echo"The message has been successfully sent i will try to email you back as soon as possible ".$name."!"; //message to be revised.
}
} else {
?>
<!-- Form Functions and Variables End -->
Form Code Starts here:
<form action="form.php?action=sendmessage" method="post" enctype="multipart/form-data" name="sendmessage" id="sendmessage">
<table width="286" border="0" cellspacing="3" cellpadding="4">
<tr>
<td width="78"><strong class="formfont">
<label for="label">First Name </label>
</strong>
<label for="label">:</label></td>
<td width="183"><input id="fname" name="fname" class="box" type="text" maxlength="255" value=""/></td>
</tr>
<tr>
<td class="formfont">Last Name:</td>
<td><input id="lname" name="lname" class="box" type="text" maxlength="255" value=""/></td>
</tr>
<tr>
<td class="formfont">E-mail:</td>
<td><input id="email" name="email" class="box" type="text" maxlength="255" value=""/></td>
</tr>
<tr>
<td class="formfont">Attach CV:</td>
<td><input id="upload" name="upload" class="box" type="file"/></td>
</tr>
<tr>
<td class="formfont">Salary:</td>
<td><select class="redopt" id="element_6" name="element_6">
<option value="12k - 16k" selected="selected" >£12k - £16k</option>
<option value="16k - 20k">£16k - £20k</option>
<option value="20k - 25k">£20k - £25k</option>
<option value="25k - 30k">£25k - £30k</option>
<option "30k or above">£30k+</option>
</select></td>
</tr>
<tr>
<td class="formfont">Skill Set:</td>
<td><select class="redopt" id="element_7" name="element_7">
<option value="Accounts" selected="selected" >Accounts</option>
<option value="Administration" >Administration</option>
<option value="Information Technology" >Information Technology</option>
<option value="Human Resources" >Human Resources</option>
<option value="Health & Safety" >Health & Safety</option>
<option value="Quality" >Quality</option>
<option value="Logistics" >Logistics</option>
<option value="Industrial" >Industrial</option>
<option value="Design" >Design</option>
<option value="Engineering - Mechanical" >Engineering - Mechanical</option>
<option value="Engineering - Electrical" >Engineering - Electrical</option>
<option value="Engineering - Subsea" >Engineering - Subsea</option>
<option value="Drilling" >Drilling</option>
<option value="Management" >Management</option>
<option value="Science" >Science</option>
<option value="Operation" >Operation</option>
<option value="Marine" >Marine</option>
</select></td>
</tr>
<tr>
<td class="formfont">Comments:</td>
<td rowspan="2"><textarea name="comments" cols="35" rows="5" class="redtxt" id="comments"></textarea></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
<td><span class="buttons">
<input id="submit" class="red" type="submit" name="submit" value="submit" />
<input id="reset" class="red" type="reset" name="reset" value="reset" />
</span></td>
</tr>
</table>
</form>