Contact form works in safari (desktop) but nothing else - php

I have a basic contact form that sends to my gmail account. This form works in Safari on my Mac but its does not work in Chrome or Opera, nor does it work on my iPhone.
The website is whataprettyface.ca/whataprettyface_new/index.html
I can get the form working in all browsers and devices when the success message is a link to a separate thank-you.html page. But I am looking for it to work the way it does currently in safari with the overlay success message.
HTML:
<form method="POST" class="ajax-form" data-message-class="colors-d background-95 heading border" action="contact.php">
<div class="row">
<div class="col-md-6 control-group">
<div class="alt-placeholder">Name</div>
<input type="text" name="name" value="" size="40" placeholder="Name" data-validation-required-message="Please fill the required field." required>
<div class="help-block"></div>
</div>
<div class="col-md-6 control-group">
<div class="alt-placeholder">Email</div>
<input type="email" name="email" value="" size="40" placeholder="Email" data-validation-required-message="Please fill the required field." required>
<div class="help-block"></div>
</div>
<div class="col-md-12 control-group">
<div class="alt-placeholder">Message</div>
<textarea name="message" placeholder="Message" data-validation-required-message="Please fill the required field." required></textarea>
<div class="help-block"></div>
</div>
<div class="col-md-12 form-actions">
<input class="button" type="submit" value="Submit">
</div>
</div>
</form>
PHP:
<?php
$errors = '';
$myemail = 'my.email#gmail.com';//
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['message']))
{
$errors .= "\n Error: all fields are required";
}
$name = $_POST['name'];
$email_address = $_POST['email'];
$message = $_POST['message'];
$successMessage = 'Message sent successfully!';
if (!preg_match(
"/^[_a-z0-9-]+(\.[_a-z0-9-]+)*#[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i",
$email_address))
{
$errors .= "\n Error: Invalid email address";
}
if( empty($errors))
{
$to = $myemail;
$email_subject = "CONTACT VIA WHATAPRETTYFACE $name";
$email_body = "\n Name: $name \n Email: $email_address \n Message \n $message";
$headers = "From: $myemail\n";
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
echo($successMessage);
}
I also have gen_validatorv31.js as a linked script.

So thanks to some the comments to the original post I was able to correct the issue by by removing the word 'contact' from my html. It now says 'kontact.php' and that spelling was reflected in the name of the php file itself.

Related

Why does using this HTML Email form is not working with this PHP code? [duplicate]

This question already has answers here:
PHP code is not being executed, but the code shows in the browser source code
(35 answers)
Send email with PHP from html form on submit with the same script
(8 answers)
Closed 3 years ago.
I'm trying to send a email by a form but its not working, everytime I try to send it asks to download the php file.
The HTML email code form is this one:
<form method="post" name="contact_form" action="contact-form-handler.php">
<div class="form-group">
<input type="text" class="form-control" placeholder="Name" name="name">
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="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="message" id="message" cols="30" rows="7" class="form-control" placeholder="Message"></textarea>
</div>
<div class="form-group">
<input type="submit" class="btn btn-primary btn-send-message" value="Send Message">
</div>
Which results the following form:
The PHP code is the following:
<?php
$errors = '';
$myemail = 'angelribeiro.10#gmail.com';
if(empty($_POST['name']) ||
empty($_POST['subject']) ||
empty($_POST['email']) ||
empty($_POST['message']))
{
$errors .= "\n Error: all fields are required";
}
$name = $_POST['name'];
$email_address = $_POST['email'];
$email_subject = $_POST['subject'];
$message = $_POST['message'];
if (!preg_match(
"/^[_a-z0-9-]+(\.[_a-z0-9-]+)*#[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i",
$email_address))
{
$errors .= "\n Error: Invalid email address";
}
if( empty($errors))
{
$to = $myemail;
$email_subject = "Contact form submission: $name";
$email_body = "You have received a new message. ".
" Here are the details:\n Name: $name \n ".
"Email: $email_address\n Message \n $message";
$headers = "From: $myemail\n";
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
//redirect to the 'thank you' page
header('Location: contact-form-thank-you.html');
}
?>
Thanks a lot.

Trouble receiving mail from application form from my website

I have added a training application form in my website. Using Modal box. This is the code
<button type="submit" onclick="document.getElementById('id01').style.display='block'" style="width:auto;">Apply Now</button>
<div id="id01" class="modal">
<span onclick="document.getElementById('id01').style.display='none'" class="close" title="Close Modal">×</span>
<form method="POST" enctype="multipart/form-data" class="modal-content" action="sendemailcontact.php">
<div class="container">
<h1>Application Form</h1>
<p>Please fill in this form to apply for the training.</p>
<hr>
<label for="name"><b>Name</b></label><br>
<input type="text" placeholder="Enter name" name="name" id="name" required><br>
<label for="email"><b>Email</b></label><br>
<input type="text" placeholder="Enter Email" name="email" id="email" required><br>
<label for="phone"><b>Phone number</b></label><br>
<input type="text" placeholder="Enter phone number" name="phone" id="phone" required><br>
<label for="location"><b>Location</b></label><br>
<input type="text" placeholder="Enter location" name="location" id="location" required><br>
<label for="college"><b>College</b></label><br>
<input type="text" placeholder="Enter college" name="college" id="college" required><br>
<!--<label for="uploaded_file"><b>Upload resume</b></label>
<input class="upl" type="file" name="uploaded_file" id="uploaded_file" required>-->
<div class="clearfix">
<input style="width:30%;" type="submit" name="apply" id="apply" class="signupbtn" value="Apply">
</div>
</div>
</form>
</div>
This form to my php code that send mail to my email address which the details received from each applicant from the above form. This is my php code
<?php
//error_reporting(-1);
//ini_set('display_errors', 'On');
//set_error_handler("var_dump");
$errors = '';
$myemail = 'example#gmail.com';
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['phone']) ||
empty($_POST['location']) ||
empty($_POST['college']))
{
$errors .= "\n Error: all fields are required";
}
$email_address = $_POST['email'];
$name = $_POST['name'];
$phno = $_POST['phone'];
$location = $_POST['location'];
$college = $_POST['college'];
if (!preg_match(
"/^[_a-z0-9-]+(\.[_a-z0-9-]+)*#[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i",
$email_address))
{
$errors .= "\n Error: Invalid email address";
}
if( empty($errors))
{
$to = $myemail;
$email_subject = "Career Oriented Training Form submission: $name";
$email_body = "You have received a new applicant. ".
" Here are the details:\n Name: $name \n Email: $email_address \n Phone: $phno \n Location: $location \n College: $college";
$headers = "From: $email_address\n";
$headers .= "Reply-To: $myemail";
mail($to,$email_subject,$email_body,$headers);
header('Location:index.html');
}
?>
When i click submit, its going to a blank page. Also i cannot receive any mail. Please help me
You need to have it echo back $errors as that will tell you why it's failing. You're stocking $errors and ignoring it other than checking that it's empty.
Also do not use regex to validate email addresses. See http://php.net/manual/en/filter.filters.validate.php specifically FILTER_VALIDATE_EMAIL

How do I get this php form to work?

Ive got a contact form thats using the same php code on another website and it works great, but on this one it will not work for some reason, after clicking send, it redirects me to a blank page saying "No Arguments Provided!". Below is the html and php for the form.
<!-- Contact form -->
<section id="contact_form">
<div class="container">
<div class="row">
<div class="col-md-6">
<h2> We would love to hear about your upcoming project.</h2>
<h2 class="second_heading">Get In Touch With Us!</h2>
</div>
<form role="form" class="form-inline text-right col-md-6" method="post" action="mail/contact_us.php" name="sentMessage" id="contactForm" novalidate>
<div class="form-group">
<input type="text" class="form-control" id="name" placeholder="Name">
</div>
<div class="form-group">
<input type="email" class="form-control" id="email" placeholder="Email">
</div>
<div class="form-group">
<textarea class="form-control" rows="5" id="msg" placeholder="Message"></textarea>
</div>
<button type="submit" class="btn submit_btn">Submit</button>
</form>
</div>
</div>
</section><!-- Contact form end -->
<?php
// check if fields passed are empty
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['msg']) ||
!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
{
echo "No arguments Provided!";
return false;
}
$name = $_POST['name'];
$email_address = $_POST['email'];
$message = $_POST['msg'];
// create email body and send it
$to = 'myemail#address.com'; // send to: email
$email_subject = "Website Contact Form: $name";
$email_body = "You have received a new message from your website contact
form.\n\n"."Here are the details:\n\nName: $name\n\nEmail:
$email_address\n\nPhone: $phone\n\nMessage:\n$message";
$headers = "From: noreply#myemail.com\n";
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
return true;
?>
All your form inputs/textareas are missing the name attribute. For example:
<input type="email" class="form-control" id="email" placeholder="Email">
Needs to be
<input type="email" class="form-control" id="email" name="email" placeholder="Email">
The name attribute is what's used when submitting a form, so as you have it, PHP isn't seeing the form fields.

Php mail and form not working [duplicate]

This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 7 years ago.
Hi I have a Contact form and a PHP file that handles the email after the form is successfully filled out. For some reason I am not receiving any emails from this form. Was just curious if my code was correct.
HTML FORM:
<form method="post" role="form" name="sentMessage" id="contactForm" action="/public_html/mail/contact_me.php" novalidate>
<div class="col-md-6">
<div class="form-group">
<input type="text" class="form-control" placeholder="Your Name *" id="name" name="name" required >
<p class="help-block text-danger"></p>
</div>
<div class="form-group">
<input type="email" class="form-control" placeholder="Your Email *" id="email" name="email" required >
<p class="help-block text-danger"></p>
</div>
<div class="form-group">
<input type="tel" class="form-control" placeholder="Your Phone *" id="phone" name="phone" required >
<p class="help-block text-danger"></p>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<textarea class="form-control" placeholder="Your Message *" id="message" name="message" required ></textarea>
<p class="help-block text-danger"></p>
</div>
</div>
<div class="clearfix"></div>
<div class="col-lg-12 text-center">
<div id="success"></div>
<button type="submit" class="btn btn-xl" >Send Message</button>
</div>
</form>
PHP CODE:
// Check for empty fields
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['phone']) ||
empty($_POST['message']) ||
!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
{
echo "No arguments Provided!";
return false;
}
$name = $_POST['name'];
$email_address = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
// Create the email and send the message
$to = 'will#blacart.com';
$email_subject = "Website Contact: $name";
$email_body = "You have received a contact request from tandemmetal.com.\n\n"."Here are the details:\n\nName: $name\n\nEmail: $email_address\n\nPhone: $phone\n\nMessage:\n$message";
$headers = "From: noreply#tandemmetals.com\n"; // This is the email address the generated message will be from. We recommend using something like noreply#yourdomain.com.
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
return true;
You can try to use \r\n instead of \n.
$headers = "From: noreply#tandemmetals.com\r\n";
$headers .= "Reply-To: $email_address\r\n";
According to http://php.net/manual/ru/function.mail.php
(in case, if your server on Windows).

php contact form, not receiving emails [duplicate]

This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 7 years ago.
please assist with my PHP form. Following this text I have both my HTML form as well as my PHP page described. I am not receiving the e-mails when I attempt to use the form on my website. I have validated that my e-mail address is working, and that should not be the issue.
The following is my HTML form:
<!-- Contact Form -->
<div class="col-md-6 col-sm-6">
<hr>
<p>Have a question or comment? Fill out the form below.</p>
<div class="contact-form wow fadeInLeft showdelay2">
<form name="sentMessage" id="contactForm" novalidate>
<div class="control-group form-group">
<div class="controls">
<label>Name</label>
<input type="text" class="form-control dark" id="name" placeholder="Name" required data-validation-required-message="Please enter your name.">
<p class="help-block"></p>
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<label>Email</label>
<input type="email" class="form-control dark" id="email" placeholder="Email Address" required data-validation-required-message="Please enter your email address.">
<p class="help-block"></p>
</div>
</div>
<div class="control-group form-group">
<div class="controls">
<label>Message</label>
<textarea class="form-control dark" rows="7" id="message" placeholder="Message" required data-validation-required-message="Please enter your message" maxlength="999" style="resize:none"></textarea>
<p class="help-block"></p>
</div>
</div>
<div id="success"></div>
<div class="pull-right">
<button type="submit" class="btn btn-info btn-lg">Submit</button>
</div>
</form>
<div class="clearfix"></div>
</div>
</div>
<!-- ./contact form -->
The following code is my contact_me.php page, which doesn't appear to be working.
<?php
// check if fields passed are empty
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['message']) ||
!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
{
echo "No arguments Provided!";
return false;
}
$name = $_POST['name'];
$email_address = $_POST['email'];
$message = $_POST['message'];
// create email body and send it
$to = 'email#addresss.com'; 'email#address.com'; // PUT YOUR EMAIL ADDRESS HERE
$email_subject = "Contact form from: $name"; // EDIT THE EMAIL SUBJECT LINE HERE
$email_body = "You have received a new message from your website's contact form.\n\n"."Here are the details:\n\nName: $name\n\nEmail: $email_address\n\nMessage:\n$message";
$headers = "From: info#bootstrapwizard.info\n";
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
return true;
?>
your to string is incorrect, the valid format is:
$to = 'AdrianPham#crosshatcheatery.com,Webmaster#crosshatcheatery.com';
the headers should end with "\r\n"
$headers = "From: info#bootstrapwizard.info\r\n";
$headers .= "Reply-To: $email_address";

Categories