使用 NL2BR 的 PHP 提交表单


php submission form using nl2br

我尝试为访问者制作一个表单,以便通过我的网站上传文件并将该文件发送到我的电子邮件。这是我的代码。但是,没有文件上传并发送到我声明的电子邮件。如果您能给我任何提示,我将不胜感激。

 <?php
 include('init.php');
$stitle="SUBMIT A MANUSCRIPT";
include ('head.php');
?>
 <link rel="stylesheet" type="text/css" href="view.css" media="all">
<script type="text/javascript" src="view.js"></script>
<table width="1100" align="center" style="border-bottom-right-radius:20px;"><td bgcolor="#ffffff">
<?php include ('nav.php'); 
if(!$_POST['title']) { ?>
<table cellspacing="4" width=100%><tr> <td bgcolor="eeeeee" width="100%" valign="top"><h3> Form</h3>
</td><td>
<body id="main_body" >

    <div id="form_container">
        <h1> Upload </h1>
        <form id="form_373615" class="appnitro" enctype="multipart/form-data" method="post" action="">
            <p>Please Complete all the boxes on this form.</p>
        </div>                      

< 
if ($_POST["email"]<>'') { 
    $ToEmail = '....'; 
    $EmailSubject = 'Site contact form'; 
    $mailheader = "From: ".$_POST["email"]."'r'n"; 
    $mailheader .= "Reply-To: ".$_POST["email"]."'r'n"; 
    $mailheader .= "Content-type: text/html; charset=iso-8859-1'r'n"; 
    $MESSAGE_BODY = "Name: ".$_POST["name"].""; 
    $MESSAGE_BODY .= "Email: ".$_POST["email"].""; 
    $MESSAGE_BODY .= "Comment: ".nl2br($_POST["comment"]).""; 
    mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); 
?> 

            <form action="test.php" method="post" enctype="multipart/form-data">
<table width="400" border="0" cellspacing="2" cellpadding="0">
<tr>
<td width="29%" class="bodytext">Your name:</td>
<td width="71%"><input name="name" type="text" id="name" size="32"></td>
</tr>
<tr>
<td class="bodytext">Email address:</td>
<td><input name="email" type="text" id="email" size="32"></td>
</tr>
<tr>
<td class="bodytext">Comment:</td>
<td><textarea name="comment" cols="45" rows="6" id="comment" class="bodytext"></textarea></td>
</tr>
<td width="29%" class="bodytext">Upload your file</td>
<td width="71%"><input type="file" name="uploaded_file"></td>
</tr>

<td align="left" valign="top"><input type="submit" name="Submit" value="Send"></td>

</p>

</tr>
</table>
</form> 

首先将文件上传到服务器上,然后将文件附加到邮件中。我希望这对你有用。