samedi 27 décembre 2014

Getting email feedback via PHP form in different file [duplicate]


This question already has an answer here:




I'm looking to implement a feedback form on a website I'm making and am running into problems when I try to separate the PHP mail script from the HTML where the form resides. Here is my PHP script:



<?php
$mail_to_send_to = "......@gmail.com";
$your_feedbackmail = "...@...coffee";

$sendflag = $_REQUEST['sendflag'];
if ( $sendflag == "send" )
{
$email = $_REQUEST['email'] ;
$name = $_REQUEST['name'] ;
$message = $_REQUEST['message'] ;
$subject = $_REQUEST['subject'] ;
$headers = "From: $your_feedbackmail" . "\r\n" . "Reply-To: $email" . "\r\n" ;
$a = mail( $mail_to_send_to, "Feedback Form Results", $message, $headers );
if ($a)
{
print("Congratulations, you've successfully entered!\r\n");
print("Be sure to 'Like' our Facebook page to complete your entry -> http://www.facebook.....\r\n");
print("We will contact you soon with more information :)");
} else {
print("Message not sent! Please contact brett@...com if you see this\r\n");
}
}
?>


If I have a simple form in index.html along with my PHP script, the mail sends and the success message prints. However, for structure reasons, I don't want the PHP to be in my large index file. Instead, put it in a file called "submit.php" and declared that as the action of my form:



<form id="contact-form" action="submit.php" method="post" enctype="text/plain">
<div class="row">
<div class="col-md-6">
// Fields ommitted
</div>
</form>


When I submit a message on the form, no email is sent, and the browser refreshes to a blank "myOriginalDomain/submit.php" site.


Where am I going wrong? Any advice as to what I'm missing is much appreciated.





Aucun commentaire:

Enregistrer un commentaire