First time here for me
I have 2 files (index.html , sendemail.php)
At index.html I have the code for my form
<section id="contact">
<div id="contact-us" class="parallax">
<div class="container">
<div class="row">
<div class="heading text-center col-sm-8 col-sm-offset-2 wow fadeInUp" data-wow-duration="1000ms" data-wow-delay="300ms">
<h2>Contact Us</h2>
<p>Request a service , learn about our services</p>
</div>
</div>
<div class="contact-form wow fadeIn" data-wow-duration="1000ms" data-wow-delay="600ms">
<div class="row">
<div class="col-sm-6">
<form id="main-contact-form" name="contact-form" method="post" enctype="multipart/form-data" action="sendemail.php">
<div class="row wow fadeInUp" data-wow-duration="1000ms" data-wow-delay="300ms">
<div class="col-sm-6">
<div class="form-group">
<input type="text" name="name" id="name" class="form-control" placeholder="Name" required="required">
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<input type="email" name="email" id="email" class="form-control" placeholder="Email Address" required="required">
</div>
</div>
</div>
<div class="form-group">
<input type="text" name="subject" id="subject" class="form-control" placeholder="Subject" required="required">
</div>
<div class="form-group">
<textarea name="message" id="message" class="form-control" rows="4" placeholder="Enter your message" required="required"></textarea>
</div>
<div class="form-group">
<button type="submit" class="btn-submit" name="submit" id="submit">Send Now</button>
</div>
</form>
</div>
<div class="col-sm-6">
<div class="contact-info wow fadeInUp" data-wow-duration="1000ms" data-wow-delay="300ms">
<p></p>
<ul class="address">
<li><i class="fa fa-phone"></i> <span> Phone:</span> +30 6982 215487 </li>
<li><i class="fa fa-envelope"></i> <span> Email:</span> info#mydomain.com</li>
<li><i class="fa fa-globe"></i> <span> Website:</span> www.mydomain.com</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
At sendemail.php I have the code
$msg = 'Name: ' .$_POST['name'] ."\n"
.'Email :' .$_POST['email'] ."\n"
.'Subject: ' .$_POST['subject'] ."\n"
.'Message: ' .$_POST['message'] ."\n";
mail('info#mydomain.com','You have one message from mydomain.com', $msg);
I get an email when i send this form but with no values into it like this
Name:
Email :
Subject:
Message:
Where is the problem with this code ?
Thanks
try change enctype in your form tag
<form id="main-contact-form" name="contact-form" method="post" enctype="application/x-www-form-urlencoded" action="sendemail.php">
also, you can print post data:
print(file_get_contents('php://input'));
If you are working on local then
you have to use library to send mail such as PHPMailer.
Check your firewall settings blocking or what.
Check any other service is using the ports (25,465,587).
If you are working on Live then
check your hosting provider allowing you to send mail.
(for this you can send test mail script directly using mail function)
If you are using library then you have to confirm with hosting
provider that they allow ports opened for send mail.
Related
</div>
<div class="row block-9">
<div class="col-md-6 order-md-last d-flex">
<form action="#" class="bg-white p-5 contact-form">
<form class="=contact-form" action="contact.php" method="post"
<div class="form-group">
<input type="text" class="form-control" placeholder="Your Name">
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="Your Email">
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="Subject">
</div>
<div class="form-group">
<textarea name="" id="" cols="30" rows="7" class="form-control" placeholder="Message"></textarea>
</div>
<div class="form-group">
<input type="submit" value="Send Message" class="btn btn-primary py-3 px-5">
</div>
</form>
</div>
<div class="col-md-6 d-flex">
<iframe src="https://www.google.com/maps/embed?pb=!1m14!1m8!1m3!1d14884.226370030301!2d79.103842!3d21.150146!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x0%3A0x5106808b025223d!2sRajshri%20Traders!5e0!3m2!1sen!2sid!4v1566792666441!5m2!1sen!2sid" width="600" height="450" frameborder="0" style="border:0;" allowfullscreen=""></iframe>
</div>
</div>
</div>
</section>
<footer class="ftco-footer ftco-section">
<div class="container">
<div class="row">
<div class="mouse">
<a href="#" class="mouse-icon">
<div class="mouse-wheel"><span class="ion-ios-arrow-up"></span></div>
</a>
</div>
</div>
<div class="row mb-5">
<div class="col-md">
<div class="ftco-footer-widget mb-4">
<h2 class="ftco-heading-2">Rajshri Traders</h2>
<p>We provide the best Cctvs.</p>
<ul class="ftco-footer-social list-unstyled float-md-left float-lft mt-5">
<li class="ftco-animate"><span class="icon-twitter"></span></li>
<li class="ftco-animate"><span class="icon-facebook"></span></li>
<li class="ftco-animate"><span class="icon-instagram"></span></li>
</ul>
</div>
</div>
<div class="col-md">
<div class="ftco-footer-widget mb-4 ml-md-5">
<h2 class="ftco-heading-2">Menu</h2>
<ul class="list-unstyled">
<li>Shop</li>
<li>About</li>
<li> </li>
<li> </li>
</ul>
</div>
</div>
<div class="col-md-4">
<div class="ftco-footer-widget mb-4">
<h2 class="ftco-heading-2"> </h2>
<div class="d-flex">
<ul class="list-unstyled mr-l-5 pr-l-3 mr-4">
<li> </li>
<li> </li>
<li> </li>
<li> </li>
</ul>
<ul class="list-unstyled">
<li> </li>
<li> </li>
</ul>
</div>
</div>
</div>
<div class="col-md">
<div class="ftco-footer-widget mb-4">
<h2 class="ftco-heading-2">Have a Questions?</h2>
<div class="block-23 mb-3">
<ul>
<li><span class="icon icon-map-marker"></span><span class="text">Plot No 1, Nike buildings, Fawara Chouk,Gandhibag, Nagpur, Maharashtra 440032, India</span></li>
<li><span class="icon icon-envelope"></span><span class="text"> rajshirtraders#gmail.com</span></li>
</ul>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 text-center">
</div>
</div>
</div>
</footer>
<!-- loader -->
<div id="ftco-loader" class="show fullscreen"><svg class="circular" width="48px" height="48px"><circle class="path-bg" cx="24" cy="24" r="22" fill="none" stroke-width="4" stroke="#eeeeee"/><circle class="path" cx="24" cy="24" r="22" fill="none" stroke-width="4" stroke-miterlimit="10" stroke="#F96D00"/></svg></div>
i am trying to link my php to the contact form but facing some issues please help
the format of the cotact us is also a bit messed up after sevral attempts to fix it i coudnt
i am using my sql for the php
i have the php file but dont know where to attach it in the contact us page (html)
i have tried a few solutions looking at youtube
but nothing works
please help
That's how work php/html:
HTML
<form class="=contact-form" action="contact.php" method="post">
<div class="form-group">
<input type="text" class="form-control" placeholder="Your Name" name="name">
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="Your Email" name="email">
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="Subject" name="subject">
</div>
<div class="form-group">
<textarea name="mess" id="" cols="30" rows="7" class="form-control" placeholder="Message" ></textarea>
</div>
<div class="form-group">
<input type="submit" value="Send Message" class="btn btn-primary py-3 px-5">
</div>
</form>
Here user will input data and sent to contact.php, i add name="" and we will create a variable with that.
PHP
// ALL VARIABLE FROM FORM
$name=$_POST['name'];
$email=$_POST['email'];
$subject=$_POST['subject'];
$message=$_POST['message'];
//NOW YOU CAN SENT EMAIL
$to = "somebody#example.com";
$headers = "From:".$email . "\r\n" .
"CC: somebodyelse#example.com";
mail($to,$subject,$message,$headers);
I am very confused that my html form action doesn't redirect me to another page, because this has always worked.
Here's my code
<section class="contact section-padding" data-scroll-index="6">
<div class="container">
<div class="row">
<div class="section-head text-center col-sm-12">
<h4>Neem contact op</h4>
<h6>Vul formulier in</h6>
</div>
<div class="offset-lg-2 col-lg-8 offset-md-1 col-md-10">
<form method="post" class="form" id="contact-form" action="verstuurd.php">
<div class="messages"></div>
<div class="controls">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<input id="form_name" type="text" name="volledige_naam" placeholder="Volledige naam">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<input id="form_email" type="email" name="email" placeholder="E-mailadres" >
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<input id="form_subject" type="text" name="subject" placeholder="Onderwerp">
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<textarea id="form_message" name="message" placeholder="Bericht" rows="4" ></textarea>
</div>
</div>
<div class="col-md-12 text-center">
<button type="submit"><span>Verstuur</span></button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</section>
What is wrong with this? I thought it might has to do something with the div classes, but is this possible?
Edit
Verstuurd.php
<section class="contact section-padding" data-scroll-index="6">
<div class="container">
<div class="row">
<div class="section-head text-center col-sm-12">
<h4>Succesvol verstuurd</h4>
<h6>We nemen zo snel mogelijk contact met u op</h6>
</div>
</div>
</div>
</section>
At the moment I do not have any php code in verstuurd.php. I thought that aciton only redirects to PHP files and not HTML files.
I'm guessing there's some javascript that is blocking the form submission. Look out for anything similar to e.preventDefault(); in relation to form submission.
Change your button from
<button type="submit"><span>Verstuur</span></button>
to
<input id="submit" name="submit" type="submit" value="Verstuur">
Hi I am new to php and am not quite sure how to do this I am attempting to build a contact form that sends an email currently the HTML I Have for the form is:
<section class="mbr-section form1 cid-qL6aon4aVW" id="form1-11">
<div class="container">
<div class="row justify-content-center">
<div class="title col-12 col-lg-8">
<h2 class="mbr-section-title align-center pb-3 mbr-fonts-style display-2">
MAINTENANCE FORM
</h2>
<h3 class="mbr-section-subtitle align-center mbr-light pb-3 mbr-fonts-style display-5">
Request Maintenance for your unit.</h3>
</div>
</div>
</div>
<div class="container">
<div class="row justify-content-center">
<div class="media-container-column col-lg-8" data-form-type="formoid">
<form class="mbr-form" action="feedback.php" method="post">
<div class="row row-sm-offset">
<div class="col-md-4 multi-horizontal" data-for="name">
<div class="form-group">
<label class="form-control-label mbr-fonts-style display-7" for="name-form1-11">Full Name</label>
<input type="text" class="form-control" name="name" data-form-field="Name" required="" placeholder="Full Name" id="name-form1-11">
</div>
</div>
<div class="col-md-4 multi-horizontal" data-for="email">
<div class="form-group">
<label class="form-control-label mbr-fonts-style display-7" for="email-form1-11">Email Address</label>
<input type="email" class="form-control" name="email" data-form-field="Email" required="" placeholder="Email" id="email-form1-11">
</div>
</div>
<div class="col-md-4 multi-horizontal" data-for="phone">
<div class="form-group">
<label class="form-control-label mbr-fonts-style display-7" for="phone-form1-11">Phone Number</label>
<input type="tel" class="form-control" name="phone" data-form-field="Phone" placeholder="Phone #" id="phone-form1-11">
</div>
</div>
</div>
<div class="form-group" data-for="message">
<label class="form-control-label mbr-fonts-style display-7" for="message-form1-11">Request</label>
<textarea type="text" class="form-control" name="message" rows="7" data-form-field="Message" placeholder="Request" id="message-form1-11"></textarea>
</div>
<span class="input-group-btn">
<button href="" type="submit" class="btn btn-primary btn-form display-4">SEND FORM</button>
</span>
</form>
</div>
</div>
</div>
And the PHP I have is :
<?php
if (isset($_POST['submit'])){
$to="email#email.com";
$subject="Shovers.net Maintenance form submission";
$mail_from="from: ".$_POST['email']." \n";
$mail_from .="Content-Type: text/html; charset=utf-8 \n";
$message="<font size=\"2\" face=\"Verdana\"> Here is the message:<br />
".$_POST['comments']."<br />
".$_POST['name']."<br />
".$_POST['email']."</font>";
mail($mail_from,$to,$subject,$comments);
echo "Thanks!";
$TARGET = "/";
header("Location: $TARGET");
exit();
}else{
}
?>
I can't seem to get this to send to my email and I am not sure why on form submit it currently just goes to the feedback.php page which is blank as it is just the PHP script. Does this need to be running on the actual server for it to work or will it work with xampp and apache/mysql running? If not what do I need to do to get this working?
In addition I am also trying to get it to just reload/stay on that same page but pop up a verification message what am I doing wrong for that?
Any help appreciated!
Thanks!
This question already has answers here:
send email through php
(2 answers)
Closed 6 years ago.
I get the email as i set to my code , but when the script executed , browser redirects me to sendemail.php and freezes there.
here is the screenshot
sendemail.php
here is the code for FORM element to my html file
</section> -->
<section id="contact">
<div id="contact-us" class="parallax">
<div class="container">
<div class="row">
<div class="heading text-center col-sm-8 col-sm-offset-2 wow fadeInUp" data-wow-duration="1000ms" data-wow-delay="300ms">
<h2>Contact Us</h2>
<p>Request a service , learn about our services</p>
</div>
</div>
<div class="contact-form wow fadeIn" data-wow-duration="1000ms" data-wow-delay="600ms">
<div class="row">
<div class="col-sm-6">
<form id="contact-form" name="contact-form" method="post" enctype="application/x-www-form-urlencoded" action="sendemail.php">
<div class="row wow fadeInUp" data-wow-duration="1000ms" data-wow-delay="300ms" id="message_form">
<div class="col-sm-6">
<div class="form-group">
<input type="text" name="name" id="name" class="form-control" placeholder="Name" required="required">
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<input type="email" name="email" id="email" class="form-control" placeholder="Email Address" required="required">
</div>
</div>
</div>
<div class="form-group">
<input type="text" name="subject" id="subject" class="form-control" placeholder="Subject" required="required">
</div>
<div class="form-group">
<textarea name="message" id="message" class="form-control" rows="4" placeholder="Enter your message" required="required"></textarea>
</div>
<div class="form-group">
<button type="submit" class="btn-submit" name="submit" id="submit">Send Now</button>
</div>
</form>
</div>
<div class="col-sm-6">
<div class="contact-info wow fadeInUp" data-wow-duration="1000ms" data-wow-delay="300ms">
<p></p>
<ul class="address">
<li><i class="fa fa-phone"></i> <span> Phone:</span> my phone </li>
<li><i class="fa fa-envelope"></i> <span> Email:</span> info#mydomain.com</li>
<li><i class="fa fa-globe"></i> <span> Website:</span> www.mydomain.com</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</section><!--/#contact-->
And here is the script that calls sendemail.php
<script type="text/javascript">
$(document).ready(function() {
$('#submit').click(function(e) {
var data = name : $("#name").val(),
subject:$("#subject").val ,
email: $("#email").val(),
message: $("#message").val()};
console.log(data);
$.ajax({
type: "post",
url: "sendemail.php",
data: data,
success: function(){
alert("it was success");
}
});
</script>
<!-- begin snippet: js hide: false console: true babel: false -->
here is the code for sendemail.php
<?php
$msg = 'Name: ' .$_POST['name'] ."\n"
.'Email :' .$_POST['email'] ."\n"
.'Subject: ' .$_POST['subject'] ."\n"
.'Message: ' .$_POST['message'] ."\n";
mail('info#mydomain.com','You have one message from santoriginal.com', $msg); ?>
WHere is the wrong to my code ?
Thanks
Your browser doesn't freeze, sendemail.php has no content.
An AJAX call to sendemail.php will not redirect you to sendemail.php, but your form does.
Try using return false; in the $('#submit').click(); this way the form is not submitted.
I am a beginner in html/wordpress css js.
I managed to convert my html site in to wordpress but on my html i had a php email form which was working fine in html but not in wordpress,
any idea what code i need and where to place?
here is the html:
<section id="contact" class="text-center">
<div class="container">
<div class="row">
<div class="col-md-12 wow fadeInDown" data-wow-delay="2000">
<h3>CONTACT US</h3>
</div>
<div class="col-md-2"></div>
<div class="col-md-8">
<p>Contact us today </p>
</div>
<div class="col-md-2"></div>
<form action="emailform.php" method="post">
<div class="col-md-4 wow fadeInLeft" data-wow-delay="2000">
<input type="text" placeholder="Name" class="form-control">
</div>
<div class="col-md-4 wow fadeInDown" data-wow-delay="2000">
<input type="email" placeholder="Email" class="form-control" required>
</div>
<div class="col-md-4 wow fadeInRight" data-wow-delay="2000">
<input type="text" placeholder="Subject" class="form-control">
</div>
<div class="col-md-12 wow fadeInDown" data-wow-delay="2000">
<textarea placeholder="Message" class="form-control"></textarea>
</div>
<div class="col-md-3"></div>
<div class="col-md-6 wow fadeInUp" data-wow-delay="2000">
<input type="submit" value="SEND MESSAGE" class="form-control">
</div>
<div class="col-md-3"></div>
</form>
</div>
</div>
To begin with you should use the name attribute on all of your inputs.
http://www.w3schools.com/tags/att_input_name.asp
Also if the file is stored within your theme you need to use
<form action="<?php echo get_template_directory(); ?>/path/to/file/emailform.php" method="post">
<form action="<?php echo get_template_directory(); ?>http://mysite.CO.UK/baca2ztheme/wp-content/themes/mytheme/emailform.php" method="post">
thats the url and now when i click on submit its as it refreshes the page. but if i manually refresh the page it says browser is trying to send information click ok to resend etc...