i have a form like this :
this is 1.php
<form action="2.php" method="post">
Name: <input type="text" name="name" /></br>
Email: <input type="text" name="email" />
<input type="submit" value="Submit" />
than 2.php is like this :
<form action="3.php" method="post">
<input type="hidden" name="name" value="<?php echo $_POST['name'];?>"/>
<input type="hidden" name="email" value="<?php echo $_POST['email'];?>"/>
Telephone: <input type="text" name="telephone" /></br>
Location: <input type="text" name="location" />
<input type="submit" value="Submit" />
and the last one 3.php is like this:
<?php
$error = "";
if(isset($_POST['submit'])) {
if(empty($_POST['email']) || empty($_POST['name'])) {
$error .= 'There is an error. Retry. <br />';
}
if(!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL)) {
$error .= 'E-mail is incorrect. <br />';
}
function sendmail() {
$to = 'user@domain.tld';
$name = "Name : " .$_POST['name'];
$telephone = "Telephone : " . $_POST['telephone']. "";
$location = "Location : " .$_POST['location'];
$subiect = "Form from webpage";
$body = 'form content: '. $name. "
". $telephone. "
" . $location. "
". $from ;
$from = "From: " . $_POST['email']. "";
if(mail($to,$subiect,$body,$from)) {
echo '<p>Thank you !</p><br />';
}else{
echo '<p>Error with server</p>';
}
}
if($error == "") {
sendmail();
}
echo "<p>".$error."</p>";
}
?>
My question is how can i introduce a <input type="file" name="file" id="file" />
in the 1st page when the user will be able to upload a photo and then on the 3.php page when he will hit the submit button that picture to be in the email
can anyone give me an example please ? Thank you !