Hi am newbie to PHP
I have a working code for what I want to do on my page but what I am looking for is help in how to add a function where somebody can attach a file to email to me.
PHP Code
<?php
.....
$errors .= "\
Error: all fields are required";
}
$name = $_POST['name'];
$age = $_POST['age'];
$lastName = $_POST['last'];
$email_address = $_POST['email'];
$sex = $_POST['sex'];
$message = $_POST['message'];
if (!preg_match(
"/^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,3})$/i",
$email_address))
{
$errors .= "\
Error: Invalid email address";
}
if( empty($errors))
{
$to = $myemail;
$email_subject = "Your Lady of interest name is: $name";
$email_body = "You have received a new message from a lovely lady. . ".
" \
Here are the details:"."\
My Name: $name $lastName \ my Age is $age \
Email: $email_address \
Message: \
$message \
would you have sex on the first date: $sex";
$headers = "From: $myemail\
";
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
//redirect to the 'thank you' page
header('Location: contact-form-thank-you.html');
}
if(isset($_POST['submitted']))
{
if($formproc->ProcessForm())
{
$formproc->RedirectToURL("thank-you.php");
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Contact form handler</title>
</head>
<body>
<!-- This page is displayed only if there is some error -->
<?php
echo nl2br($errors);
?>
</body>
</html>
HTMLCode
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Dating Thank message been sent</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="description" content="singles, Asians, Dating, quensland, Cairns" >
<meta name="keywords" content="Dean ,Ross, Dean Ross, Looking to date single Asians, Looking to date single Pilipino, Looking to date single Indian, Looking to date single Japanese , Dating ,girls only, Romance, Looking for a relationship, relationships, Love, lonely, singles, Dating in Queensland, Dating in Cairns, Dating Cairns, Dating Queensland, Queensland , Cairns, desperate and lonely, single men, single guys, men, guys" >
<meta name="robots" content="all" >
<meta name="robots" content="looking for - single men guys">
<meta name="revisit-after" content="15 days">
<meta name="FORMATTER" content="Dean Ross 2014">
<meta name="resource-type" content="document">
<meta name="rating" content="general">
<meta name="country" content="Australia">
<meta name="coverage" content="Australia">
<LINK rel="stylesheet" type="text/css" href="xenaStyle.css">
</head><body class="mainB" leftmargin="1" topmargin="1" bgproperties="fixed" marginwidth="0" oncontextmenu="return false">
<div id="rightMain" class="ThankYou">
<div class="Thanks">Contact me</div>
</div><br>
<div id="Main" class="Main">
<table>
<tr>
<td><img src="MEDean3.jpg" width="450" height="338"></td>
<td><table width="100%" border="0">
<tr>
<td class="black"><em class="black">My Height</em></td>
<td>152 cm</td>
</tr>
<tr>
<td><em class="black">My Age</em></td>
<td>43 Years old</td>
</tr>
<tr>
<td><em class="black">My Wieght</em></td>
<td>52Kg</td>
</tr>
<tr>
<td><em class="black">My build</em></td>
<td>Average</td>
</tr>
<tr>
<td colspan="2" > </td>
</tr>
</table>
</td>
</tr>
</table>
Please ONLY geniune Lady should message me no players!!<br>
<font class="red">Please make sure that you fill in all feild or form will fail to send</font>
<form method="POST" name="contactform" action="contact-form-handler.php">
<label for='name'>Your Name:</label>
<input name="name" type="text" size="15">
<label for='last'>Your Last name:</label>
<input name="last" type="text" size="15">
<label for='age'>Your Age:</label>
<input type="text" name="age" size="15"><br>
<label for='email'>Email Address:</label> <br>
<input name="email" type="text" size="68"> <br>
<label for='message'>Message: please leave a brief meaage about youself and some contact details</label> <br>
<textarea name="message" cols="53" rows="5"></textarea><br>
<label for="sex">would you have sex on the first date</label>
<select name="sex" id="sex">
<option value="Yes - if it felt right at the time.">Yes - if it felt right at the time.</option>
<option value="No- Please do not askme again">No- Please do not askme again</option>
</select><br>
<label for='photo'> Please upload a Photograph</label>
<label for='photo' >Upload your photo:</label><br/>
<span id='contactus_photo_errorloc' class='error'></span> <input type="file" name='photo' id='photo' />
<input type="submit" value="Send Email"> <input type="reset" value="Reset Form"><br>
</form>
<script language="JavaScript">
// Code for validating the form
// Visit http://www.javascript-coder.com/html-form/javascript-form-validation.phtml
// for details
var frmvalidator = new Validator("contactform");
frmvalidator.addValidation("name","req","Please provide your name");
frmvalidator.addValidation("email","req","Please provide your email");
frmvalidator.addValidation("email","email","Please enter a valid email address");
</script>
</div>
</body>
</html>