php отправка формы по email
что бы при использовании второго кода посилалось форма
1,
Код:
<?php
//vars
$subject = $_POST['subject'];
$to = explode(',', $_POST['to'] );
$from = $_POST['email'];
//data
$msg = "NAME: " .$_POST['name'] ."<br>\n";
$msg .= "EMAIL: " .$_POST['email'] ."<br>\n";
$msg .= "WEBSITE: " .$_POST['web'] ."<br>\n";
$msg .= "COMMENTS: " .$_POST['comments'] ."<br>\n";
//Headers
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=UTF-8\r\n";
$headers .= "From: <".$from. ">" ;
//send for each mail
foreach($to as $mail){
mail($mail, $subject, $msg, $headers);
}
?>
//vars
$subject = $_POST['subject'];
$to = explode(',', $_POST['to'] );
$from = $_POST['email'];
//data
$msg = "NAME: " .$_POST['name'] ."<br>\n";
$msg .= "EMAIL: " .$_POST['email'] ."<br>\n";
$msg .= "WEBSITE: " .$_POST['web'] ."<br>\n";
$msg .= "COMMENTS: " .$_POST['comments'] ."<br>\n";
//Headers
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=UTF-8\r\n";
$headers .= "From: <".$from. ">" ;
//send for each mail
foreach($to as $mail){
mail($mail, $subject, $msg, $headers);
}
?>
Код:
<!-- form -->
<script type="text/javascript" src="js/form-validation.js"></script>
<form id="contactForm" action="#" method="post">
<fieldset>
<p>
<label>NAME:</label>
<input name="name" id="name" type="text" />
</p>
<p>
<label>EMAIL:</label>
<input name="email" id="email" type="text" />
</p>
<p>
<label>WEB:</label>
<input name="web" id="web" type="text" />
</p>
<p>
<label>COMMENTS:</label>
<textarea name="comments" id="comments" rows="5" cols="20" ></textarea>
</p>
<!-- send mail configuration -->
<input type="hidden" value="email@server.com" name="to" id="to" />
<input type="hidden" value="From torn wordpress online" name="subject" id="subject" />
<input type="hidden" value="send-mail.php" name="sendMailUrl" id="sendMailUrl" />
<!-- ENDS send mail configuration -->
<p><input type="button" value="SEND" name="submit" id="submit" /></p>
</fieldset>
<p id="error" class="warning">Message</p>
</form>
<p id="success" class="success">Thanks for your comments.</p>
<!-- ENDS form -->
<script type="text/javascript" src="js/form-validation.js"></script>
<form id="contactForm" action="#" method="post">
<fieldset>
<p>
<label>NAME:</label>
<input name="name" id="name" type="text" />
</p>
<p>
<label>EMAIL:</label>
<input name="email" id="email" type="text" />
</p>
<p>
<label>WEB:</label>
<input name="web" id="web" type="text" />
</p>
<p>
<label>COMMENTS:</label>
<textarea name="comments" id="comments" rows="5" cols="20" ></textarea>
</p>
<!-- send mail configuration -->
<input type="hidden" value="email@server.com" name="to" id="to" />
<input type="hidden" value="From torn wordpress online" name="subject" id="subject" />
<input type="hidden" value="send-mail.php" name="sendMailUrl" id="sendMailUrl" />
<!-- ENDS send mail configuration -->
<p><input type="button" value="SEND" name="submit" id="submit" /></p>
</fieldset>
<p id="error" class="warning">Message</p>
</form>
<p id="success" class="success">Thanks for your comments.</p>
<!-- ENDS form -->
$from = $_POST['email']; ну так вот тут email можешь свой написать любой $from = "vasya@mail.ru"