Ussing reCAPTCHA on HTML5 whit contact-form.php - php

I have a website Html5 and try adding the reCaptcha still sending messages without activating the reCaptcha and last night I received over 300 messages a boot.
Help me please how to add so that only sent when the button is activated reCaptcha.
Send sends works well but not activation reCaptcha.
To start contact.html within my template I have put this way:
<!-- Start formulario de contacto -->
<div class="row">
<div class="col-md-9">
<h2>Formulario de contacto</h2>
<form action="php/contact-form.php" id="contact-form">
<div class="alert alert-success hidden" id="contact-alert-success">
<strong>Mensaje enviado correctamente!</strong> Muchas gracias, pronto nos pondremos en contacto con usted, normalmente nuestro tiempo de respuesta es inferior a 2 horas.
</div>
<div class="alert alert-danger hidden" id="contact-alert-error">
<strong>Error!</strong> A sucedido un error si lo desea puede contactarnos directamente en XXXX#tize.XXXX
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label>Nombre <span class="required">*</span></label>
<input type="text"
value=""
data-msg-required="Por favor introduzca su nombre"
class="form-control"
name="name" id="name">
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label>eMail <span class="required">*</span></label>
<input type="email"
value=""
data-msg-required="Por favor introduzca su eMail"
data-msg-email="Por favor introduzca un eMail válido"
class="form-control"
name="email"
id="email">
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label>Asunto <span class="required">*</span></label>
<input type="text"
value=""
data-msg-required="Por favor introduzca el asunto"
class="form-control"
name="subject"
id="subject">
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Mensaje <span class="required">*</span></label>
<textarea
data-msg-required="Por favor introduzca su mensaje"
rows="10"
class="form-control"
name="message"
id="message"></textarea>
</div>
</div>
</div>
<!-- Start Google Recaptcha -->
<div class="g-recaptcha" data-sitekey="6Lc88P4SAAAAANiT-ZXILUo-ET4xQmbivHy7uHc8"></div><br>
<!-- End Google Recaptcha -->
<div class="row">
<div class="col-md-12">
<input type="submit" value="Enviar mensaje" class="btn btn-primary" data-loading-text="Cargando...">
</div>
</div>
</form>
</div>
<!-- End formulario de contacto -->
And in php form to send the messages have this post with contact-form.php :
<?php
session_cache_limiter('nocache');
header('Expires: ' . gmdate('r', 0));
header('Content-type: application/json');
// Enter your email address
$to = 'XXXX#tize.XX';
$subject = $_POST['subject'];
if($to) {
$name = $_POST['name'];
$email = $_POST['email'];
$fields = array(
0 => array(
'text' => 'Name',
'val' => $_POST['name']
),
1 => array(
'text' => 'Email address',
'val' => $_POST['email']
),
2 => array(
'text' => 'Message',
'val' => $_POST['message']
)
);
$message = "";
foreach($fields as $field) {
$message .= $field['text'].": " . htmlspecialchars($field['val'], ENT_QUOTES) . "<br>\n";
}
$headers = '';
$headers .= 'From: ' . $name . ' <' . $email . '>' . "\r\n";
$headers .= "Reply-To: " . $email . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
if (mail($to, $subject, $message, $headers)){
$arrResult = array ('response'=>'success');
} else{
$arrResult = array ('response'=>'error');
}
echo json_encode($arrResult);
} else {
$arrResult = array ('response'=>'error');
echo json_encode($arrResult);
}
?>
Picture of my form, If anyone wants to see my website please let me know and send you the link. Thank you very much.
sending without activating the reCaptcha http://goo.gl/oSLQG9

Related

Cannot POST / contact_process.php

i've tried to create this contact form and here is the HTML code:
<section class="contact_info_area sec_pad bg_color">
<div class="container">
<div class="row">
<div class="col-lg-3 pr-0">
<div class="contact_info_item">
<h6 class="f_p f_size_20 t_color3 f_500 mb_20">Información de contacto</h6>
<p class="f_400 f_size_15"><span class="f_400 t_color3">Email:</span> admin#doupmedia.com</p>
</div>
</div>
<div class="col-lg-8 offset-lg-1">
<div class="contact_form">
<form action="contact_process.php" class="contact_form_box" method="post" id="contactForm" novalidate="novalidate">
<div class="row">
<div class="col-lg-6">
<div class="form-group text_box">
<input type="text" id="name" name="name" placeholder="Tu Nombre">
</div>
</div>
<div class="col-lg-6">
<div class="form-group text_box">
<input type="text" name="email" id="email" placeholder="Correo Electrónico">
</div>
</div>
<div class="col-lg-12">
<div class="form-group text_box">
<input type="text" id="subject" name="subject" placeholder="Asunto">
</div>
</div>
<div class="col-lg-12">
<div class="form-group text_box">
<input type="text" id="subject" name="subject" placeholder="Teléfono">
</div>
</div>
<div class="col-lg-6">
<div class="form-group text_box">
<input type="text" id="subject" name="subject" placeholder="Página Web de la Empresa">
</div>
</div>
<div>
<script>
$('.calendar').flatpickr({
locale:"es",
minDate: "today",
"disable": [
function(date) {
// return true to disable
return (date.getDay() === 0 || date.getDay() === 6);
}
],
"locale": {
"firstDayOfWeek": 1 // start week on Monday
}
})
</script>
</div>
<div>
<label for="country">Tamaño de clientes aproximado</label>
<select id="clientes" name="country">
<option value="australia">0 - 1k</option>
<option value="canada">1k - 10k</option>
<option value="usa">100k - 1M</option>
<option value="usa">1M - 10M</option>
</select>
<label for="country">¿A qué hora va bien que te llamemos?</label>
<select id="clientes" name="country">
<option value="australia">10:00 - 11:00</option>
<option value="canada">11:00 - 12:00</option>
<option value="usa">12:00 - 13:00</option>
<option value="usa">13:00 - 14:00</option>
<option value="usa">16:00 - 17:00</option>
<option value="usa">17:00 - 18:00</option>
<option value="usa">18:00 - 19:00</option>
<option value="usa">19:00 - 20:00</option>
</select>
</div>
<div class="col-lg-12">
<div class="form-group text_box">
<textarea name="message" id="message" cols="30" rows="10" placeholder="Deja tu mensaje..."></textarea>
</div>
</div>
</div>
<div class="custom-control custom-switch custom-switch-light">
<input type="checkbox" class="custom-control-input" id="customSwitch2" required="">
<label class="custom-control-label" for="customSwitch2">He leído y acepto la política de privacidad y protección de datos.</label>
</div>
<br>
<button type="submit" class="btn_three" >Enviar Mensaje</button>
</form>
<div id="success">¡En breves nos pondremos en contacto contigo!</div>
<div id="error">Opps! Ha habido un error. Porfavor inténtelo de nuevo.</div>
</div>
</div>
</div>
</div>
</section>
And when I try to edit the contact.php which is called contact_process.php it jumps a white page with thhat error: Cannot POST / contact_process.php
If somebody knows the answer please help.
<?php
$to = "runjiebusiness#gmail.com";
$from = $_REQUEST['email'];
$name = $_REQUEST['name'];
$name2 = $_REQUEST['name2'];
$csubject = $_REQUEST['subject'];
$cmessage = $_REQUEST['message'];
$headers = "From: $from";
$headers = "From: " . $from . "\r\n";
$headers .= "Reply-To: ". $from . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$subject = "You have a message from your Doup Media.";
$logo = '';
$link = '#';
$body = "<!DOCTYPE html><html lang='en'><head><meta charset='UTF-8'><title>Bixcoin Master Mail</title></head><body>";
$body .= "<table style='width: 100%;'>";
$body .= "<thead style='text-align: center;'><tr><td style='border:none;' colspan='2'>";
$body .= "<a href='{$link}'><img src='{$logo}' alt=''></a><br><br>";
$body .= "</td></tr></thead><tbody><tr>";
$body .= "<td style='border:none;'><strong>Name:</strong> {$name}</td>";
$body .= "<td style='border:none;'><strong>Email:</strong> {$from}</td>";
$body .= "</tr>";
$body .= "<tr><td style='border:none;'><strong>Subject:</strong> {$csubject}</td></tr>";
$body .= "<tr><td></td></tr>";
$body .= "<tr><td colspan='2' style='border:none;'>{$cmessage}</td></tr>";
$body .= "</tbody></table>";
$body .= "</body></html>";
$send = mail($to, $subject, $body, $headers);
?>
the _REQUEST variable is missing the field "name2". so the PHP script fails:
$name2 = $_REQUEST['name2'];
This means you need to add an input in your form for name2 or remove this in your PHP script.

Input radio not sending data

I have a simple contact form, the html is this part:
<!-- CONTACT FORM -->
<form id="contact-form" name="contactform" class="row">
<!-- CONTACT FORM IMPUT -->
<div id="input_name" class="col-md-12">
<input type="text" name="name" id="name" class="form-control" placeholder="Il tuo nome">
</div>
<div id="input_email" class="col-md-12">
<input type="text" name="email" id="email" class="form-control" placeholder="Email">
</div>
<div id="input_subject" class="col-md-12">
<input type="text" name="subject" id="subject" class="form-control" placeholder="Numero di telefono">
</div>
<div id="input_message" class="col-md-12">
<textarea class="form-control" name="message" id="message" rows="6" placeholder="Il tuo messaggio..."></textarea>
</div>
<div class="col-md-12 sinistra"><br>Quale servizio ti interessa?<br><br></div>
<div class="col-md-4 sinistra">
<input type="radio" name="tipologia" value="standard"> Standard<br>
</div>
<div class="col-md-4 sinistra">
<input type="radio" name="tipologia" value="avanzato"> Avanzato<br>
</div>
<div class="col-md-4 sinistra">
<input type="radio" name="tipologia" value="deluxe"> Deluxe<br>
</div>
<div class="col-md-12"><br></div>
<!-- CONTACT FORM SUBMIT BUTTON -->
<div id="form_btn" class="col-md-12">
<input type="submit" value="Invia" id="submit" class="btn btn-small btn-blue">
</div>
<!-- CONTACT FORM MESSAGE -->
<div class="col-md-12 contact-form-msg">
<span class="loading"></span>
</div>
</form>
with this php file
<?
$name = $_REQUEST["name"];
$email = $_REQUEST["email"];
$subject = $_REQUEST["subject"];
$msg = $_POST["msg"];
$tipologia = $_POST['tipologia'] ;
$to = "info#gmail.com";
if (isset($email) && isset($name) && isset($msg) ) {
$email_subject = "$name ha inviato una richiesta di ordine";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= "Da: ".$name." <".$email.">\r\n"."Reply-To: ".$email."\r\n" ;
$msg = "Da: $name<br/> Email: $email <br/> Telefono: $subject <br/>
Tipologia: $tipologia <br/> Messaggio: $msg";
$mail = mail($to, $email_subject, $msg, $headers);
if($mail)
{
echo 'success';
}
else
{
echo 'failed';
}
}
?>
but I have a problem with radio input, the form works but doesn't pass the value of radio to email, so the email has the Tipologia without the radio selected for the form... What could be the error?
<form> defaults to a GET method if POST isn't implied.
You're using two POST arrays.
So... use a POST method and all POST arrays.
Either way, everything must match.
You should also check if the radio buttons are set or not, or any other you wish to include.

Contact form with select field issues

I've got some troubles about my contact form, i tried many solutions but it still doesnt work.
I've got a basic contact form with basic inputs and a select field. All the fields are sent by email except the datas in my select field.
Here's my HTML form :
<section class="section-signup bg-faded mt80">
<div class="container">
<div class="row">
<h3 class="text-xs-center">Je veux devenir un point de vente</h3>
<p class="subform m-b-3">Merci de préciser si vous êtes une entreprise, un courtier, un investisseur, un professionnel ou autre</p>
<div class="form-bottom contact-form">
<form role="form" action="contact.php" method="post">
<div class="form-group col-md-4">
<label for="email_expediteur">Votre adresse e-mail :</label>
<input type="text" name="email" placeholder="Email..." class="contact-email form-control" id="contact-email">
</div>
<div class="form-group col-md-4">
<label for="email_expediteur">Sujet :</label>
<input type="text" name="subject" placeholder="Sujet..." class="contact-subject form-control" id="contact-subject">
</div>
<div class="col-md-4 form-group">
<label for="jesuis">Je suis : </label>
<select class="form-control" name="jesuis">
<option value="">Selectionnez...</option>
<option value="entreprise">Une entreprise</option>
<option value="courtier">Un courtier</option>
<option value="investisseur">Un investisseur</option>
<option value="professionnel">Un professionnel</option>
<option value="autre">Autre</option>
</select>
</div>
<div class="col-md-12 form-group">
<label for="contact-message">Message :</label>
<textarea name="message" placeholder="Message..." class="contact-message form-control" id="contact-message"></textarea>
</div>
<div class="col-md-12 form-group">
<label for="contact-antispam">Question Antispam : 7 + 5 = ?</label>
<input type="text" name="antispam" placeholder="Votre réponse..." class="contact-antispam form-control" id="contact-antispam">
</div>
<div class="col-md-6 col-md-offset-3 form-group centered">
<button type="submit" class="btn">Envoyer</button>
</div>
</form>
</div>
</div>
</div>
</section>
And here's my contact.php :
<?php
// Email address verification
function isEmail($email) {
return filter_var($email, FILTER_VALIDATE_EMAIL);
}
if($_POST) {
// Enter the email where you want to receive the message
$emailTo = 'info#yachtbox.net';
$clientEmail = addslashes(trim($_POST['email']));
$subject = addslashes(trim($_POST['subject']));
$message = addslashes(trim($_POST['message']));
$antispam = addslashes(trim($_POST['antispam']));
$jesuis = addslashes(trim($_POST['jesuis']));
$array = array('emailMessage' => '', 'subjectMessage' => '', 'messageMessage' => '', 'antispamMessage' => '', 'jesuisMessage' =>'');
if(!isEmail($clientEmail)) {
$array['emailMessage'] = 'Email Invalide';
}
if($subject == '') {
$array['subjectMessage'] = 'Sujet manquant';
}
if($message == '') {
$array['messageMessage'] = 'Message manquant';
}
if($antispam != '12') {
$array['antispamMessage'] = 'Mauvaise réponse';
}
if($jesuis == '') {
$array['jesuisMessage'] = 'Merci de préciser si vous êtes une entreprise, un courtier, un investisseur, un professionnel ou autre';
}
if(isEmail($clientEmail) && $subject != '' && $message != '' && $antispam == '12' && $jesuis != '') {
// Send email
$headers = "From: " . $clientEmail . " <" . $clientEmail . ">" . "\r\n" . "Reply-To: " . $clientEmail;
mail($emailTo, $subject . " (Formulaire de contact MUST Assurances)", $message, $headers, $jesuis);
}
echo json_encode($array);
}
?>
Do you have any ideas ?
Cheers.
Loïc
$message = "Je suis un(e) ".$jesuis." ".$message;
mail($emailTo, $subject . " (Formulaire de contact MUST Assurances)", $message, $headers);
Your 5th parameter didn't make sense.

Email contact-form based in php and html not working

I'm creating a website with a template from templateforest. I have an HTML contact form which is integrated at the bottom of the site and it is related with a PHP file for the submit process.
Here you are the code from the HTML part:
<!--contact section start-->
<div class="section section-contact" id="contact">
<div class="container">
<div class="row">
<div class="col-md-12">
<!--tittle start-->
<div class="tittle">
<h1>
<a name="contactar"><span>10</span></a>
Contactar</h1>
<h2>
<span> Si deseas ponerte en contacto conmigo por favor, rellena el siguiente formulario o si lo prefieres utiliza los datos de contacto facilitados al pie de esta página.</span>
</h2>
</div>
<!--tittle end-->
<div class="contact-row">
<form role="form" class="form-horizontal">
<div class="row form-group">
<div class="col-sm-4 col-xs-12">
<input type="text" name="name" placeholder="Name" class="form-control">
</div>
<div class="col-sm-4 col-xs-12">
<input type="text" name="email" placeholder="Email" class="form-control">
</div>
<div class="col-sm-4 col-xs-12">
<input type="text" name="subject" placeholder="Subject" class="form-control">
</div>
</div>
<div class="row form-group">
<div class="col-xs-12">
<textarea name="comments" placeholder="Comments" class="form-control" rows="10" cols="30" id="msg" name=""></textarea>
</div>
</div>
<div class="row form-group text-center">
<div class="col-xs-12">
<button type="submit" id="submit" class="view-btn">Contactar con Patricia</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<!--contact section end-->
And this is the code from sendmail.php file:
<?php
// Note: filter_var() requires PHP >= 5.2.0
if ( isset($_POST['name']) && isset($_POST['email']) && isset($_POST['subject']) && isset($_POST['comments']) && filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) ) {
// detect & prevent header injections
$mailTest = "/(content-type|bcc:|cc:|to:)/i";
foreach ( $_POST as $key => $val ) {
if ( preg_match( $mailTest, $val ) ) {
exit;
}
}
$headers = 'From: ' . $_POST["name"] . '<' . $_POST["email"] . '>' . "\r\n" .
'Reply-To: ' . $_POST["email"] . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail( "info#example.com", $_POST['subject'], $_POST['comments'], $headers );
// Replace with your email
}
?>
Obviously I've replaced the "info#example.com" with a valid email... but it didn't work.
I've looking for similar codes but I'm not very good at php so I can't find the solution.
When I push on "submit" button at the site, it just reloads the whole page... and that's all... no error message but also no email sent.
The php version of the server is 5.4.
EDIT AT 13/05/2015:
This is the PHP File code after the changes I've performed as they were sugested:
<?php
//this is to activate error messages
error_reporting(E_ALL);
ini_set('display_errors', 1);
// Note: filter_var() requires PHP >= 5.2.0
if ( isset($_POST['name']) && isset($_POST['email']) && isset($_POST['subject']) && isset($_POST['comments']) && filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) ) {
// detect & prevent header injections
$mailTest = "/(content-type|bcc:|cc:|to:)/i";
foreach ( $_POST as $key => $val ) {
if ( preg_match( $mailTest, $val ) ) {
exit;
}
}
$headers = 'From: ' . $_POST["name"] . '<' . $_POST["email"] . '>' . "\r\n" .
'Reply-To: ' . $_POST["email"] . "\r\n" .
'X-Mailer: PHP/' . phpversion();
if(mail( "info#example.com", $subject, $comment, $headers )){
echo "Mail sent, it's out of your hands now and it did its job.";
}
else{
echo "There was an error, check your logs.";
}
// Replace with your email
}
?>
EDIT 2:
Now the HTML code looks like this:
<!--contact section start-->
<div class="section section-contact" id="contact">
<div class="container">
<div class="row">
<div class="col-md-12">
<!--tittle start-->
<div class="tittle">
<h1>
<a name="contactar"><span>10</span></a>
Contactar</h1>
<h2>
<span> Si deseas ponerte en contacto conmigo por favor, rellena el siguiente formulario o si lo prefieres utiliza los datos de contacto facilitados al pie de esta página.</span>
</h2>
</div>
<!--tittle end-->
<div class="contact-row">
<form role="form" class="form-horizontal" action="sendmail.php">
<div class="row form-group">
<div class="col-sm-4 col-xs-12">
<input type="text" name="name" placeholder="Name" class="form-control">
</div>
<div class="col-sm-4 col-xs-12">
<input type="text" name="email" placeholder="Email" class="form-control">
</div>
<div class="col-sm-4 col-xs-12">
<input type="text" name="subject" placeholder="Subject" class="form-control">
</div>
</div>
<div class="row form-group">
<div class="col-xs-12">
<textarea name="comments" placeholder="Comments" class="form-control" rows="10" cols="30" id="msg" name=""></textarea>
</div>
</div>
<div class="row form-group text-center">
<div class="col-xs-12">
<button type="submit" id="submit" class="view-btn">Contactar con Patricia</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
Seeing that what you posted for code, am submitting the following and taken from my comments.
Forms default to a GET method if a POST method isn't explicitly used.
You're using POST arrays, so make your form a POST method.
<form method="post" role="form" class="form-horizontal">
^^^^^^^^^^^^^
Unless you've got some JS/Ajax you're not showing us that does have a $.post or POST method in there, you will need to post that, after the fact.
"no error message but also no email sent."
That's because you're not checking for them.
Add error reporting to the top of your file(s) which will help find errors.
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
// rest of your code
Sidenote: Error reporting should only be done in staging, and never production.
Footnotes:
You shouldn't pass POST arrays like this:
mail( "info#example.com", $_POST['subject'], $_POST['comments'], $headers );
You're leaving yourself open to XSS injection.
You should use pre-assigned variables.
$subject = $_POST['subject'];
$comment = $_POST['comments'];
...
mail( "info#example.com", $subject, $comment, $headers );
or
if(mail( "info#example.com", $subject, $comment, $headers )){
echo "Mail sent, it's out of your hands now and it did its job.";
}
else{
echo "There was an error, check your logs.";
}
XSS injection articles:
http://en.wikipedia.org/wiki/Cross-site_scripting
Cross-site Scripting (XSS) - OWASP
Edit:
<?php
//this is to activate error messages
error_reporting(E_ALL);
ini_set('display_errors', 1);
// Note: filter_var() requires PHP >= 5.2.0
if ( isset($_POST['name']) && isset($_POST['email']) && isset($_POST['subject']) && isset($_POST['comments']) && filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) ) {
// detect & prevent header injections
$mailTest = "/(content-type|bcc:|cc:|to:)/i";
foreach ( $_POST as $key => $val ) {
if ( preg_match( $mailTest, $val ) ) {
exit;
}
}
$subject = $_POST['subject'];
$comment = $_POST['comments'];
$headers = 'From: ' . $_POST["name"] . '<' . $_POST["email"] . '>' . "\r\n" .
'Reply-To: ' . $_POST["email"] . "\r\n" .
'X-Mailer: PHP/' . phpversion();
if(mail( "info#example.com", $subject, $comment, $headers )){
echo "Mail sent, it's out of your hands now and it did its job.";
}
else{
echo "There was an error, check your logs.";
}
// Replace with your email
}
?>

PHP files open while clicking on send

this is my code in HTML5
whenever i am clicking on send button ...
phpfiles open rather mailing on that mail id which I mentioned can anybody help me out please ???
<div class="col-md-6">
<div class="alert alert-success hidden" id="contactSuccess">
<strong>Success!</strong> Your message has been sent to us.</div>
<div class="alert alert-danger hidden" id="contactError">
<strong>Error!</strong> There was an error sending your message.</div>
<h2 class="short">
<strong>Contact</strong> Us</h2>
<form action="php/contact-form.php" id="contactForm" type="post">
<div class="row">
<div class="form-group">
<div class="col-md-6">
<label>Your name *</label>
<input type="text" value="" data-msg-required="Please enter your name." maxlength="100" class="form-control"
name="name" id="name" /></div>
<div class="col-md-6">
<label>Your email address *</label>
<input type="email" value="" data-msg-required="Please enter your email address."
data-msg-email="Please enter a valid email address." maxlength="100" class="form-control" name="email"
id="email" /></div>
</div>
</div>
<div class="row">
<div class="form-group">
<div class="col-md-12">
<label>Subject</label>
<input type="text" value="" data-msg-required="Please enter the subject." maxlength="100" class="form-control"
name="subject" id="subject" /></div>
</div>
</div>
<div class="row">
<div class="form-group">
<div class="col-md-12">
<label>Message *</label>
<textarea maxlength="5000" data-msg-required="Please enter your message." rows="10" class="form-control" name="message"
id="message"></textarea></div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<input type="submit" value="Send Message" class="btn btn-primary btn-lg" data-loading-text="Loading..." />
</div>
</div>
</form>
</div>
======================================================
and dis are my codes in php file...
<?php
session_cache_limiter('nocache');
header('Expires: ' . gmdate('r', 0));
header('Content-type: application/json');
// Enter your email address below.
$to = 'info#webppulse.com';
$subject = $_POST['subject'];
if($to) {
$name = $_POST['name'];
$email = $_POST['email'];
$fields = array(
0 => array(
'text' => 'Name',
'val' => $_POST['name']
),
1 => array(
'text' => 'Email address',
'val' => $_POST['email']
),
2 => array(
'text' => 'Message',
'val' => $_POST['message']
)
);
$message = "";
foreach($fields as $field) {
$message .= $field['text'].": " . htmlspecialchars($field['val'], ENT_QUOTES) . "<br>\n";
}
$headers = '';
$headers .= 'From: ' . $name . ' <' . $email . '>' . "\r\n";
$headers .= "Reply-To: " . $email . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
if (mail($to, $subject, $message, $headers)){
$arrResult = array ('response'=>'success');
} else{
$arrResult = array ('response'=>'error');
}
echo json_encode($arrResult);
} else {
$arrResult = array ('response'=>'error');
echo json_encode($arrResult);
}
?>
whenever i am clicking on send button ...
phpfiles open rather mailing on that mail id can someone help me out please ?
Change the following code
<form action="php/contact-form.php" id="contactForm" type="post">
with
<form action="php/contact-form.php" id="contactForm" method="post">
You Must have install localhost server Like xampp or wampp.
Then put files in
For Xampp : htdocx/ Put your file in htdocx folder and run.
Foe wampp: www/ put your file in www folder and run.
Turn your type="post" into a method="post". Also, you need to have your project placed into the htdocs folder of your WAMP directory and ensure that the WAMP server has been turned on.
You should always try a "Hello World" test first to ensure that everything is running correctly. Check out tutorials on the Web for this.

Categories