1

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 = '[email protected]';
            $name = "Name : " .$_POST['name'];
            $telephone = "Telephone : " . $_POST['telephone']. "";
            $location = "Location : " .$_POST['location'];
            $subiect = "Form from webpage";
            $body = 'form content: '. $name. "\n". $telephone. "\n\n" . $location. "\n\n". $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 !

2
  • Save image in temp folder, keep the file name in session, attatch it on third php Commented Jun 12, 2012 at 20:47
  • possible duplicate of Sending an attachment with php Commented Jun 12, 2012 at 20:50

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.