Simple Lack of Knowledge

Hi Guys,

I am having some trouble creating a form process due to a simple lack of knowlegde.

Here is my current php code:

[code]<?php

$EmailFrom = "[email protected]";
$EmailTo = "[email protected]";
$Subject = “New Candidate Registration”;
$name = Trim(stripslashes($_POST[‘name’]));
$email = Trim(stripslashes($_POST[‘email’]));
$telephone = Trim(stripslashes($_POST[‘telephone’]));
$location = Trim(stripslashes($_POST[‘location’]));
$attachcv = Trim(stripslashes($_POST[‘attachcv’]));
$coveringletter = Trim(stripslashes($_POST[‘coveringletter’]));

// validation
$validationOK=true;
if (Trim($name)=="") $validationOK=false;
if (Trim($email)=="") $validationOK=false;
if (Trim($telephone)=="") $validationOK=false;
if (!$validationOK) {
print “<meta http-equiv=“refresh” content=“0;URL=…/…/error”>”;
exit;
}

// email body text
$Body = “”;
$Body .= "Name: ";
$Body .= $name;
$Body .= “\n”;
$Body .= "Email: ";
$Body .= $email;
$Body .= “\n”;
$Body .= "Telephone: ";
$Body .= $telephone;
$Body .= “\n”;
$Body .= "Location: ";
$Body .= $location;
$Body .= “\n”;
$Body .= "Attach CV: ";
$Body .= $attachcv;
$Body .= “\n”;
$Body .= "Covering Letter: ";
$Body .= $coveringletter;
$Body .= “\n”;

// send email
$success = mail($EmailTo, $Subject, $Body, “From: <$EmailFrom>”);

// redirect to success page
if ($success){
print “<meta http-equiv=“refresh” content=“0;URL=…/…/sent”>”;
}
else{
print “<meta http-equiv=“refresh” content=“0;URL=…/…/error”>”;
}
?>[/code]

And here is the front end HTML code:

<form name="submit-cv" id="submit-cv" action="_layout/php/submit-cv.php" method="post">


	<table>
	<tbody><tr>
		<td>
			Your Name: <font color="#DA1623">*</font><br />
			<input id="name" class="text" type="text" value="" name="name">
		</td>
		<td>
			Email Address: <font color="#DA1623">*</font><br />
			<input id="email" class="text" type="text" value="" name="email">
		</td>
	</tr>
	<tr>
		<td>
			Telephone: <font color="#DA1623">*</font><br />
			<input id="telephone" class="text" type="text" value="" name="telephone">
		</td>
		<td>
			Location:<br />
			<input id="location" class="text" type="text" value="" name="location">
		</td>
	</tr>

<tr>
		<td colspan="2">
			Attach CV:<br />
			<input type="file" name="attachcv" id="attachcv" /> 
		</td>
	</tr>
	<tr>
		<td colspan="2">
			Covering Letter:<br />
			<textarea name="coveringletter" rows="5" cols="20"></textarea>
		</td>
	</tr>
	</tbody></table>

	<input type="submit" name="submit" value="Send Details">

	</form>

At the moment, as you can see the attach CV field is a simple text entry field - I want to make this a file upload field which will then attach the file to the email that it sends to me.

Any assistance in this would be fantastic.

Best,

Scott.

look up email headers…

I’m not sure a simple from is good enough for a basic email, but you’ll need to setup your attachment within your headers so you can do both at the same time.

There’s a lot more that goes into an email header than what you have.

Sponsor our Newsletter | Privacy Policy | Terms of Service