简体   繁体   English

使用nl2br的php提交表格

[英]php submission form using nl2br

I try to make a form for visitors to upload a file via my site and send that file to my e-mail. 我尝试为访问者创建一个表格,以便通过我的网站上传文件并将该文件发送到我的电子邮件中。 This is my code. 这是我的代码。 However no file is uploaded and sent to my declared e-mail. 但是,没有文件上传并发送到我声明的电子邮件中。 I would appreciate it if you could give me any hint. 如果您能给我任何提示,我将不胜感激。

 <?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> 

First upload the file on server and then attach the file to mail. 首先将文件上传到服务器,然后将文件附加到邮件。 I hope this will work for you. 希望对您有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM