I have just finished creating fire by scratching my head while creating a contact form which sends email to me with the users inputted info, its only basic but im now going to be using the base of that to start a job application form which should not be to hard... my problem is that I want the user to be able to attach their CV to the form...
I have been playing around with this which i took out of a pre written script which i was directed to on an old forum post... really can not get it to work... PLEASE HELP ME BEFORE I BURN MY COMPUTER! :argh:
applyforajob.php
<div class="column1-unit">
<div class="contactform">
<form method="POST" action="applysettings.php" enctype="multipart/form-data">
<fieldset><legend> Candidate Details </legend>
<p><label for="contact_title">Title:* </label><br>
<select name="contact_title" class="combo">
<option value="Choose"> Select... </option>
<option value="Mr"> Mr. </option>
<option value="Mrs"> Mrs. </option>
<option value="Ms"> Ms. </option>
<option value="Miss"> Miss. </option>
<option value="Dr"> Dr. </option></select>
<p>First Name:* <br>
<input type="text" name="Firstname" class="field" value="" tabindex="1">
<p>Surname:* <br>
<input type="text" name="Surname" class="field" value="" tabindex="2">
<p>Date Of Birth:* <br>
<input type="text" name="DOB" class="field" value="DD/MM/YYYY" tabindex="3">
<p>First Line Of Address:* <br>
<input type="text" name="Address1" class="field" value="" tabindex="4">
<p>City:* <br>
<input type="text" name="Address2" class="field" value="" tabindex="5">
<p>Postcode:* <br>
<input type="text" name="Postcode" class="field" value="" tabindex="6">
<p>Email Address:* <br>
<input type="text" name="EmailFrom" class="field" value="" tabindex="7">
<p>Contact Number:* <br>
<input type="text" name="Telephone" class="field" value="" tabindex="8">
</fieldset>
<fieldset><legend> Eligibility - Please Delete As Applicable </legend>
<p>Can you provide a passport showing you are a British Citizen, or have a right of abode in the United
Kingdom:<br>
<input type="radio" name="elig1" value="Yes" tabindex="9">Yes <br>
<input type="radio" name="elig1" value="No" tabindex="9">No <p>
<h3>NOTE: If the above question has been answered Yes - Please skip to qualifactions & education</h3><p>
<p>Can you provide a document showing that you are a national of a European Economic Area country
or Switzerland. This must be a national passport or national identity card:<br>
<input type="radio" name="elig2" value="Yes" tabindex="10">Yes <br>
<input type="radio" name="elig2" value="No" tabindex="10">No
<p>Can you provide a residence permit issued by the Home Office to a national from a European
Economic Area country or Switzerland:<br>
<input type="radio" name="elig3" value="Yes" tabindex="11">Yes <br>
<input type="radio" name="elig3" value="No" tabindex="11">No
<p>Can you provide a passport or other document issued by the Home Office which has an endorsement
stating that you have a current right of residence in the United Kingdom as the family
member of a national from a European Economic Area country or Switzerland who is
resident in the United Kingdom:<br>
<input type="radio" name="elig4" value="Yes" tabindex="12">Yes <br>
<input type="radio" name="elig4" value="No" tabindex="12">No
<p>Can you provide a passport or other travel document endorsed to show that you can stay indefinitely
in the United Kingdom, or has no time limit on your stay:<br>
<input type="radio" name="elig5" value="Yes" tabindex="13">Yes <br>
<input type="radio" name="elig5" value="No" tabindex="13">Yes
<p>Can you provide a a passport or other travel document endorsed to show that you can stay in the
United Kingdom; and that this endorsement allows you to do the type of work we are
offering if you do not have a work permit:<br>
<input type="radio" name="elig6" value="Yes" tabindex="14">Yes<br>
<input type="radio" name="elig6" value="No" tabindex="14">No
<p>Can you provide an Application Registration Card issued by the Home Office stating you are
permitted to take employment:<br>
<input type="radio" name="elig7" value="Yes" tabindex="15">Yes <br>
<input type="radio" name="elig7" value="No" tabindex="15">No <p>
If None Of The Above Can Be Provided Please Do Not Continue With This Application.
</fieldset>
<fieldset><legend> Qualifactions & Education: </legend>
<p>Please provide details of your education so far:<br>
<textarea name="Education" id="Education" cols="55" rows="10" tabindex="16"></textarea></p> </fieldset>
<fieldset><legend> Employment History: </legend>
<p>Please provide details of your previous employment:<br>
<p>Name Of Employer:<br>
<input type="text" name="Employer_Name" class="field" value="" tabindex="17"> <p>
<p>Employer Address:<br>
<input type="text" name="Employer_Address" class="field" value="" tabindex="18"> <p>
<p>Superviser Or Manager Name:<br>
<input type="text" name="Manager_Name" class="field" value="" tabindex="19"> <p>
<p>Employers Contact Number:<br>
<input type="text" name="Employer_Contact" class="field" value="" tabindex="20"> <p>
<p>Employers Email Address:<br>
<input type="text" name="Employer_Email" class="field" value="" tabindex="21"> <p>
<p>Position Title:<br>
<input type="text" name="Position_Title" class="field" value="" tabindex="22"> <p>
<p>Salary:<br>
<input type="text" name="Salary" class="field" value="" tabindex="23"> <p>
<p>Reason For Leaving:<br>
<input type="text" name="Leaving_Reason" class="field" value="" tabindex="24"> <p>
<p>Responsibilities:<br>
<textarea name="Responsibilities" id="Responsibilities" cols="55" rows="10" tabindex="25"></textarea></p>
<p>May We Contact Your Employer:<br>
<input type="radio" name="Can_We_Contact" value="Yes" tabindex="26">Yes <BR>
<input type="radio" name="Can_We_Contact" value="No" tabindex="26">No <p>
</fieldset>
<fieldset><legend> Employer References: </legend>
<p>Name / Relationship / Address / Phone:<br>
<textarea name="Referances" id="Referances" cols="55" rows="10" tabindex="27"></textarea></p>
</fieldset>
<fieldset><legend> Position Applying For & Why You Think Your Suitable: </legend>
<P><label for="Position">Please State Which Position You Are Applying For:* </label><br>
<select name="Position" class="combo" tabindex="28">
<option value="choose"> Select... </option>
<option value="Accounts_Manager"> SME Business Accounts Manager. </option>
<option value="Senior_Accounts_Manager"> Senior SME Business Accounts Manager. </option>
<option value="Administrator"> Administrator. </option>
<option value="Human_Resources_Officer"> Human Resources Officer. </option> <p> </select>
<p>Please Upload Your CV:<br>
<p><input type="file" name="attachment"></p>
<p>Why You Think You Are Suitable For The Role:<br>
<textarea name="Whyyou" id="Whyyou" cols="55" rows="10" tabindex="29"></textarea></p> </fieldset>
<p><input type="submit" name="submit" value="Submit" class="button" tabindex="30">
</form>
</div>
</div>
Question
chrismarsden
Hi guys, I was wondering if you could help me:
I have just finished creating fire by scratching my head while creating a contact form which sends email to me with the users inputted info, its only basic but im now going to be using the base of that to start a job application form which should not be to hard... my problem is that I want the user to be able to attach their CV to the form...
I have been playing around with this which i took out of a pre written script which i was directed to on an old forum post... really can not get it to work... PLEASE HELP ME BEFORE I BURN MY COMPUTER! :argh:
applyforajob.php
<div class="column1-unit"> <div class="contactform"> <form method="POST" action="applysettings.php" enctype="multipart/form-data"> <fieldset><legend> Candidate Details </legend> <p><label for="contact_title">Title:* </label><br> <select name="contact_title" class="combo"> <option value="Choose"> Select... </option> <option value="Mr"> Mr. </option> <option value="Mrs"> Mrs. </option> <option value="Ms"> Ms. </option> <option value="Miss"> Miss. </option> <option value="Dr"> Dr. </option></select> <p>First Name:* <br> <input type="text" name="Firstname" class="field" value="" tabindex="1"> <p>Surname:* <br> <input type="text" name="Surname" class="field" value="" tabindex="2"> <p>Date Of Birth:* <br> <input type="text" name="DOB" class="field" value="DD/MM/YYYY" tabindex="3"> <p>First Line Of Address:* <br> <input type="text" name="Address1" class="field" value="" tabindex="4"> <p>City:* <br> <input type="text" name="Address2" class="field" value="" tabindex="5"> <p>Postcode:* <br> <input type="text" name="Postcode" class="field" value="" tabindex="6"> <p>Email Address:* <br> <input type="text" name="EmailFrom" class="field" value="" tabindex="7"> <p>Contact Number:* <br> <input type="text" name="Telephone" class="field" value="" tabindex="8"> </fieldset> <fieldset><legend> Eligibility - Please Delete As Applicable </legend> <p>Can you provide a passport showing you are a British Citizen, or have a right of abode in the United Kingdom:<br> <input type="radio" name="elig1" value="Yes" tabindex="9">Yes <br> <input type="radio" name="elig1" value="No" tabindex="9">No <p> <h3>NOTE: If the above question has been answered Yes - Please skip to qualifactions & education</h3><p> <p>Can you provide a document showing that you are a national of a European Economic Area country or Switzerland. This must be a national passport or national identity card:<br> <input type="radio" name="elig2" value="Yes" tabindex="10">Yes <br> <input type="radio" name="elig2" value="No" tabindex="10">No <p>Can you provide a residence permit issued by the Home Office to a national from a European Economic Area country or Switzerland:<br> <input type="radio" name="elig3" value="Yes" tabindex="11">Yes <br> <input type="radio" name="elig3" value="No" tabindex="11">No <p>Can you provide a passport or other document issued by the Home Office which has an endorsement stating that you have a current right of residence in the United Kingdom as the family member of a national from a European Economic Area country or Switzerland who is resident in the United Kingdom:<br> <input type="radio" name="elig4" value="Yes" tabindex="12">Yes <br> <input type="radio" name="elig4" value="No" tabindex="12">No <p>Can you provide a passport or other travel document endorsed to show that you can stay indefinitely in the United Kingdom, or has no time limit on your stay:<br> <input type="radio" name="elig5" value="Yes" tabindex="13">Yes <br> <input type="radio" name="elig5" value="No" tabindex="13">Yes <p>Can you provide a a passport or other travel document endorsed to show that you can stay in the United Kingdom; and that this endorsement allows you to do the type of work we are offering if you do not have a work permit:<br> <input type="radio" name="elig6" value="Yes" tabindex="14">Yes<br> <input type="radio" name="elig6" value="No" tabindex="14">No <p>Can you provide an Application Registration Card issued by the Home Office stating you are permitted to take employment:<br> <input type="radio" name="elig7" value="Yes" tabindex="15">Yes <br> <input type="radio" name="elig7" value="No" tabindex="15">No <p> If None Of The Above Can Be Provided Please Do Not Continue With This Application. </fieldset> <fieldset><legend> Qualifactions & Education: </legend> <p>Please provide details of your education so far:<br> <textarea name="Education" id="Education" cols="55" rows="10" tabindex="16"></textarea></p> </fieldset> <fieldset><legend> Employment History: </legend> <p>Please provide details of your previous employment:<br> <p>Name Of Employer:<br> <input type="text" name="Employer_Name" class="field" value="" tabindex="17"> <p> <p>Employer Address:<br> <input type="text" name="Employer_Address" class="field" value="" tabindex="18"> <p> <p>Superviser Or Manager Name:<br> <input type="text" name="Manager_Name" class="field" value="" tabindex="19"> <p> <p>Employers Contact Number:<br> <input type="text" name="Employer_Contact" class="field" value="" tabindex="20"> <p> <p>Employers Email Address:<br> <input type="text" name="Employer_Email" class="field" value="" tabindex="21"> <p> <p>Position Title:<br> <input type="text" name="Position_Title" class="field" value="" tabindex="22"> <p> <p>Salary:<br> <input type="text" name="Salary" class="field" value="" tabindex="23"> <p> <p>Reason For Leaving:<br> <input type="text" name="Leaving_Reason" class="field" value="" tabindex="24"> <p> <p>Responsibilities:<br> <textarea name="Responsibilities" id="Responsibilities" cols="55" rows="10" tabindex="25"></textarea></p> <p>May We Contact Your Employer:<br> <input type="radio" name="Can_We_Contact" value="Yes" tabindex="26">Yes <BR> <input type="radio" name="Can_We_Contact" value="No" tabindex="26">No <p> </fieldset> <fieldset><legend> Employer References: </legend> <p>Name / Relationship / Address / Phone:<br> <textarea name="Referances" id="Referances" cols="55" rows="10" tabindex="27"></textarea></p> </fieldset> <fieldset><legend> Position Applying For & Why You Think Your Suitable: </legend> <P><label for="Position">Please State Which Position You Are Applying For:* </label><br> <select name="Position" class="combo" tabindex="28"> <option value="choose"> Select... </option> <option value="Accounts_Manager"> SME Business Accounts Manager. </option> <option value="Senior_Accounts_Manager"> Senior SME Business Accounts Manager. </option> <option value="Administrator"> Administrator. </option> <option value="Human_Resources_Officer"> Human Resources Officer. </option> <p> </select> <p>Please Upload Your CV:<br> <p><input type="file" name="attachment"></p> <p>Why You Think You Are Suitable For The Role:<br> <textarea name="Whyyou" id="Whyyou" cols="55" rows="10" tabindex="29"></textarea></p> </fieldset> <p><input type="submit" name="submit" value="Submit" class="button" tabindex="30"> </form> </div> </div>applysettings.php
<?php // get posted data into local variables $EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); $EmailTo = "chris_mars@hotmail.co.uk"; $Subject = "Website Application"; $contact_title = Trim(stripslashes($_POST['contact_title'])); $Firstname = Trim(stripslashes($_POST['Firstname'])); $Surname = Trim(stripslashes($_POST['Surname'])); $DOB = Trim(stripslashes($_POST['DOB'])); $Address1 = Trim(stripslashes($_POST['Address1'])); $Address2 = Trim(stripslashes($_POST['Address2'])); $Postcode = Trim(stripslashes($_POST['Postcode'])); $Telephone = Trim(stripslashes($_POST['Telephone'])); $elig1 = Trim(stripslashes($_POST['elig1'])); $elig2 = Trim(stripslashes($_POST['elig2'])); $elig3 = Trim(stripslashes($_POST['elig3'])); $elig4 = Trim(stripslashes($_POST['elig4'])); $elig5 = Trim(stripslashes($_POST['elig5'])); $elig6 = Trim(stripslashes($_POST['elig6'])); $elig7 = Trim(stripslashes($_POST['elig7'])); $Education = Trim(stripslashes($_POST['Education'])); $Employer_Name = Trim(stripslashes($_POST['Employer_Name'])); $Employer_Address = Trim(stripslashes($_POST['Employer_Address'])); $Manager_Name = Trim(stripslashes($_POST['Manager_Name'])); $Employer_Contact = Trim(stripslashes($_POST['Employer_Contact'])); $Employer_Email = Trim(stripslashes($_POST['Employer_Email'])); $Position_Title = Trim(stripslashes($_POST['Position_Title'])); $Salary = Trim(stripslashes($_POST['Salary'])); $Leaving_Reason = Trim(stripslashes($_POST['Leaving_Reason'])); $Responsibilities = Trim(stripslashes($_POST['Responsibilities'])); $Can_We_Contact = Trim(stripslashes($_POST['Can_We_Contact'])); $Referances = Trim(stripslashes($_POST['Referances'])); $attachment = Trim(stripslashes($_POST['attachment'])); $Position = Trim(stripslashes($_POST['Position'])); $Whyyou = Trim(stripslashes($_POST['Whyyou'])); $attachment_fields[1] = Trim(stripslashes($_POST['attachments'])); $attachment_fields[1]=""; // validation $validationOK=true; if (Trim($contact_title)=="choose") $validationOK=false; if (Trim($EmailFrom)=="") $validationOK=false; if (Trim($Firstname)=="") $validationOK=false; if (Trim($Surname)=="") $validationOK=false; if (Trim($DOB)=="") $validationOK=false; if (Trim($Address1)=="") $validationOK=false; if (Trim($Address2)=="") $validationOK=false; if (Trim($Postcode)=="") $validationOK=false; if (Trim($Telephone)=="") $validationOK=false; if (Trim($Position)=="") $validationOK=false; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=errorapp.php\">"; exit; } // prepare email body text $Body = ""; $Body .= "Title: "; $Body .= $contact_title; $Body .= "\n"; $Body .= "\n"; $Body .= "First Name: "; $Body .= $Firstname; $Body .= "\n"; $Body .= "\n"; $Body .= "Surname: "; $Body .= $Surname; $Body .= "\n"; $Body .= "\n"; $Body .= "DOB: "; $Body .= $DOB; $Body .= "\n"; $Body .= "\n"; $Body .= "First Line Of Address: "; $Body .= $Address1; $Body .= "\n"; $Body .= "\n"; $Body .= "Second Line Of Address: "; $Body .= $Address2; $Body .= "\n"; $Body .= "\n"; $Body .= "Post Code: "; $Body .= $Postcode; $Body .= "\n"; $Body .= "\n"; $Body .= "Contact Number: "; $Body .= $Telephone; $Body .= "\n"; $Body .= "\n"; $Body .= "Eligibility Answer 1: "; $Body .= $elig1; $Body .= "\n"; $Body .= "\n"; $Body .= "Eligibility Answer 2: "; $Body .= $elig2; $Body .= "\n"; $Body .= "\n"; $Body .= "Eligibility Answer 3: "; $Body .= $elig3; $Body .= "\n"; $Body .= "\n"; $Body .= "Eligibility Answer 4: "; $Body .= $elig4; $Body .= "\n"; $Body .= "\n"; $Body .= "Eligibility Answer 5: "; $Body .= $elig5; $Body .= "\n"; $Body .= "\n"; $Body .= "Eligibility Answer 6: "; $Body .= $elig6; $Body .= "\n"; $Body .= "\n"; $Body .= "Eligibility Answer 7: "; $Body .= $elig7; $Body .= "\n"; $Body .= "\n"; $Body .= "Education: "; $Body .= $Education; $Body .= "\n"; $Body .= "\n"; $Body .= "Previous Employer Name: "; $Body .= $Employer_Name; $Body .= "\n"; $Body .= "\n"; $Body .= "Employers Address: "; $Body .= $Employer_Address; $Body .= "\n"; $Body .= "\n"; $Body .= "Manager Name: "; $Body .= $Manager_Name; $Body .= "\n"; $Body .= "\n"; $Body .= "Employer Phone Number: "; $Body .= $Employer_Contact; $Body .= "\n"; $Body .= "\n"; $Body .= "Employer Email: "; $Body .= $Employer_Email; $Body .= "\n"; $Body .= "\n"; $Body .= "Position Held: "; $Body .= $Position_Title; $Body .= "\n"; $Body .= "\n"; $Body .= "Salary: "; $Body .= $Salary; $Body .= "\n"; $Body .= "\n"; $Body .= "Reason For Leaving: "; $Body .= $Leaving_Reason; $Body .= "\n"; $Body .= "\n"; $Body .= "Responsibilities Held: "; $Body .= $Responsibilities; $Body .= "\n"; $Body .= "\n"; $Body .= "Can We Contact Previous Employer: "; $Body .= $Can_We_Contact; $Body .= "\n"; $Body .= "\n"; $Body .= "Referances: "; $Body .= $Referances; $Body .= "\n"; $Body .= "\n"; $Body .= "Position Applying For: "; $Body .= $Position; $Body .= "\n"; $Body .= "\n"; $Body .= "Why The Candidate Is Applying: "; $Body .= $Whyyou; $Body .= "\n"; $Body .= "\n"; $Body .= "Attachment: "; $Body .= $attachment_fields[1]; $Body .= "\n"; $Body .= "\n"; function getAttachments($attachment_fields, $message, $content_type, $border) { $att_message="This is a multi-part message in MIME format.\r\n"; $att_message.="--{$border}\r\n"; $att_message.=$content_type."\r\n"; $att_message.="Content-Transfer-Encoding: 7bit\r\n\r\n"; $att_message.=$message."\r\n\r\n"; $att_check=preg_split('/,/',$attachment_fields); $att_run=sizeof($att_check); for($i=0;$i<$att_run;$i++) { $fileatt=$_FILES[$att_check[$i]]['tmp_name']; $fileatt_name=$_FILES[$att_check[$i]]['name']; $fileatt_type=$_FILES[$att_check[$i]]['type']; if (is_uploaded_file($fileatt)) { $file=fopen($fileatt,'rb'); $data=fread($file,filesize($fileatt)); fclose($file); $data=chunk_split(base64_encode($data)); $att_message.="--{$border}\n"; $att_message.="Content-Type: {$fileatt_type}; name=\"{$fileatt_name}\"\r\n"; $att_message.="Content-Disposition: attachment; filename=\"{$fileatt_name}\"\r\n"; $att_message.="Content-Transfer-Encoding: base64\r\n\r\n".$data."\r\n\r\n"; } } $att_message.="--{$border}--\n"; return $att_message; } // send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=okapp.php\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=errorapp.php\">"; } ?>Link to comment
Share on other sites
9 answers to this question
Recommended Posts