I trying to add a file upload button to a php form to either email or upload to a directory on a our server. I cant figure this one out.
[B]careers.htm code:
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”
“
<html>
<head>
<title>Advertising at Hope Today </title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
<style type=”text/css”>
<!–
.style11 {font-size: 12px; color: #444; font-family: Arial;}
.style14 {color: #444444;
font-weight: bold;
}
.style15 {font-size: medium}
–>
</style>
<script language=”JavaScript” type=”text/JavaScript”>
<!–
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf(“?”))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors=”,args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!=””) {
if (test.indexOf(‘isEmail’)!=-1) { p=val.indexOf(‘@’);
if (p<1 || p==(val.length-1)) errors+=’- ‘+nm+’ must contain an e-mail address.n’;
} else if (test!=’R’) { num = parseFloat(val);
if (isNaN(val)) errors+=’- ‘+nm+’ must contain a number.n’;
if (test.indexOf(‘inRange’) != -1) { p=test.indexOf(‘:’);
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+=’- ‘+nm+’ must contain a number between ‘+min+’ and ‘+max+’.n’;
} } } else if (test.charAt(0) == ‘R’) errors += ‘- ‘+nm+’ is required.n’; }
} if (errors) alert(‘The following error(s) occurred:n’+errors);
document.MM_returnValue = (errors == ”);
}
//–>
</script>
</head>
<body>
<form method=”POST” action=”mailertestnewAd.php”>
<p>Advertisiting </p>
<div align=”left”>
<table width=”291″ height=”212″ border=”0″>
<tr>
<td>Email:</td>
<td> </td>
<td><input name=”email” type=”text” onSelect=”MM_validateForm(’email’,”,’RisEmail’);return document.MM_returnValue” size=”25″></td>
</tr>
<tr>
<td width=”60″>Company Name </td>
<td width=”3″> </td>
<td width=”221″><input name=”cname” type=”text” id=”cname” onSelect=”MM_validateForm(’email’,”,’RisEmail’);return document.MM_returnValue” size=”25″></td>
</tr>
<tr>
<td>Name: </td>
<td> </td>
<td><input name=”name” type=”text” id=”name” size=”25″></td>
</tr>
<tr>
<td>Address: </td>
<td> </td>
<td><input type=”text” name=”address” size=”25″></td>
</tr>
<tr>
<td>City: </td>
<td> </td>
<td><input type=”text” name=”city” size=”25″></td>
</tr>
<tr>
<td>State: </td>
<td> </td>
<td><input type=”text” name=”state” size=”25″></td>
</tr>
<tr>
<td>Zip:</td>
<td> </td>
<td><input type=”text” name=”zip” size=”25″></td>
</tr>
<tr>
<td>Phone: </td>
<td> </td>
<td><input type=”text” name=”phone” size=”25″></td>
</tr>
<tr>
<td>Line of Business </td>
<td> </td>
<td><input name=”lofb” type=”text” id=”lofb” size=”25″></td>
</tr>
</table>
</div>
<p align=”left”> </p>
<p align=”left”> <span class=”style11″><span class=”body style7″><span class=”style10 body style16″><strong>Message:</strong></span></span></span><span class=”caption”><br>
</span>
<textarea rows=”10″ name=”message” cols=”30″></textarea>
<span class=”caption”> <br>
<br>
<input name=”Submit” type=”submit” id=”Submit” value=”Submit”>
<input name=”reset” type=”reset” id=”reset” value=”Reset”>
</span></p>
</form>
<p></p>
</body>
</html>
[B]mailertestnewcareer.php code:
<?php
$to = “
$subject = “Advertising Information; #set the subject line
$headers = “From: Form Mailer”; #set the from address
$message = “”; #set the from address
$forward = 1; # redirect? 1 : yes || 0 : no
$location = “
$headers = “From: ” . $_POST[“name”];
$headers .= “<” . $
$headers .= “Reply-To: ” . $_POST[“email”] . “rn”;
$headers .= “Return-Path: ” . $
$message .= “nn”;
$message .= “Email: ” . $_POST[“email”] . “rn”;
$message .= “Company Name: ” . $
$message .= “Name: ” . $_POST[“name”] . “rn”;
$message .= “Address: ” . $
$message .= “City: ” . $_POST[“city”] . “rn”;
$message .= “State: ” . $
$message .= “Zip Code: ” . $_POST[“zip”] . “rn”;
$message .= “Phone: ” . $
$message .= “Line of Business: ” . $_POST[“lofb”] . “rnn”;
$message .= “Message: ” . $
mail($to, $subject, $message, $headers);
if ($forward == 1) {
header (“Location:$location”);
}
else {
echo (“Thank you for submitting our form. We will get back to you as soon as possible.”);
}
?>
[upl-file uuid=64ab8a45-b756-4bfd-9d5a-907ba567ecf6 size=2kB]careerform.zip