Forum Moderators: coopster
I want people to be able to enter their details and attach a photo of themselves and then the script emails this to my email address and if possible auto resizes their image if it too large. Im saving the images to a folder on the site and plan on putting a link in the email to the image. If its possible to send the email with the image just in their it would be better, but I havnt been able to figure out how that would work.
Any help would be much appreciated. Here is my code so far, I know it has alot of more work to be done, but im kind of stuck now.
function cleanInput($value){
if(function_exists(strip_tags)){
$value = strip_tags($value);
}if(function_exists(mysql_real_escape_string)){
$value = mysql_real_escape_string($value);
}else if(function_exists(mysql_escape_string)){
$value = mysql_escape_string($value);
}
if(function_exists(addslashes)){
$value = addslashes($value);
}else{
$value = str_replace("'", "´", $value);
$value = str_replace('"', '"', $value);
}
return $value;
}
if( empty( $_POST['name'] ) ¦¦ empty( $_POST['dob'] ) ¦¦ empty( $_POST['phone'] ) ¦¦ empty( $_POST['photo'] ) ¦¦ empty( $_POST['chk1'] ) ¦¦ empty( $_POST['chk2'] ) ){
$name = cleanInput( $_POST['name'] );
$dob = cleanInput( $_POST['dob'] );
$phone = cleanInput( $_POST['phone'] );
$imgfile = $_FILES['image']['name'];
$chk1 = cleanInput( $_POST['chk1'] );
$chk2 = cleanInput( $_POST['chk2'] );
if (is_uploaded_file($imgfile))
{
$newfile = "http://www.thebahamahut.co.nz/job_imgs/" . $name . rand(0,100) . $imgfile;
if (!copy($imgfile, $newfile))
{
echo "Error Uploading File.";
exit();
}else{
echo "ok!";
}
}
}else{
echo "FAIL!";
}
?>
<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
<strong>Name:</strong> <input name="name" id="joinUs_name" type="text" value="" /><br />
<strong>Date of Birth:</strong> <input name="dob" id="joinUs_dob" type="text" value="" /><br />
<strong>Contact phone number:</strong> <input name="phone" id="joinUs_phone" type="text" value="" /><br /><br />
<strong>Attach your photo:</strong> <input type="file" name="photo" id="joinUs_file" /><br /><br />
Your Application will be more sucessful with a photo. Tick if understood
<input type="checkbox" name="chk1" id="chk1" value="checkbox">
<br /><br />
This doesnt mean you are guaranteed a job. Tick if Agreed
<input type="checkbox" name="chk2" id="chk2" value="checkbox">
<br /><br />
<input type="submit" name="joinUsSubmit" value="SUBMIT" />
</form>
For emailing image as attachment, use phpMailer class. [sourceforge.net...]