dimanche 28 décembre 2014

Contact form not working in wordpress


I am creating a wordpress theme for my website in which there is a contact form in index.php. For my contact form i am using following code. However, it's not working as expected. It's working fine in my simple PHP website but while doing same in wordpress its not working. Its showing invalid access message.


Also, while navigating to other pages its showing this error


Warning: Cannot modify header information - headers already sent by (output started at /home/newskijj/public_html/blog/wp-content/themes/nss wp test/functions.php:112) in /home/newskijj/public_html/blog/wp-includes/pluggable.php on line 1121


I've used various contact plugins also but they are not working. Also, used contact form of various theme but again same problem. What should i do? Plzz help



<div class="block-content">

<?php
if(isset($_POST['submit'])) {
$to = "raunakhajela@gmail.com"; // this is your Email address
$from = $_POST['email']; // this is the sender's Email address
$name = $_POST['first_name'];
$subject = "Form submission";
$subject2 = "Copy of your form submission";
$message = $name . " " . " wrote the following:" . "\n\n" . $_POST['message'];

$headers = "From: info@newskoolstudios.net" . "\r\n" .
"BCC: raunakhajela608@gmail.com". "\r\n" .
"CC: raunakhajela608@gmail.com";

$flag=mail($to,$subject,$message,$headers); // sends a copy of the message to the sender
if($flag)
{
echo "Mail Sent. Thank you " . $name . ", we will contact you shortly.";
}
else
{
echo 'Fail to send mail';
}
}
else {
echo "Invalid access!!";
}
?>

<form action="index.php" method="post" class="trigger-form-animate">
<input type="text" name="name" value="" placeholder="Name *" />
<input type="text" name="email" value="" placeholder="Email *" />
<input type="text" name="website" value="" placeholder="Website (optional)" />
<textarea type="text" value="" rows="3" name="message" placeholder="Your Message *" ></textarea> <div class="clr"></div>
<button name="submit">Submit Message</button>
</form>

</div>




Aucun commentaire:

Enregistrer un commentaire