1

我有这样的表格:

这是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" />

比 2.php 是这样的:

<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" />

最后一个 3.php 是这样的:

<?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. "\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>";
    }            
?>

<input type="file" name="file" id="file" />我的问题是,当用户能够上传照片时,我如何在第一页中引入 a ,然后在 3.php 页面上,当他点击提交按钮时,该图片将出现在电子邮件中

谁能给我一个例子吗?谢谢 !

4

0 回答 0