Last active
August 14, 2021 17:15
-
-
Save codigoconjuan/093f8135b990bc0884b1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$name = $_POST['name']; | |
$email = $_POST['email']; | |
$message = $_POST['messageField']; | |
$header = 'From: ' . $email . " \r\n"; | |
$header .= "X-Mailer: PHP/" . phpversion() . " \r\n"; | |
$header .= "Mime-Version: 1.0 \r\n"; | |
$header .= "Content-Type: text/plain"; | |
$comment .= "This message was sent by: " . $name . " \r\n"; | |
$comment .= "His email is: " . $email . " \r\n"; | |
$comment .= "The message is: ". $message ." \r\n"; | |
$for = 'blackmaxxgdl18@hotmail.com'; | |
$subject = 'You have a new email from your website!'; | |
mail($for, $subject, utf8_decode($comment), $header); | |
// server response! | |
$nombre = $_POST['nombre']; | |
echo json_encode(array( | |
'message' => sprintf('Your email has been received %s', $name), | |
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<section id="support" class="azulBG"> | |
<h1 class="text-center">Support</h1> | |
<div class="separator"></div> | |
<p class="text-center">Contact us filling the next form</p> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-md-8 col-md-offset-2"> | |
<form id="supportForm" class="form-horizontal" method="post" class="form-horizontal" action="ajaxSubmit.php"> | |
<div class="form-group"> | |
<div class="col-sm-12"> | |
<input type="text" class="form-control field" placeholder="Your Name" name="name" required> | |
</div> | |
</div> | |
<div class="form-group"> | |
<div class="col-sm-12"> | |
<input type="email" class="form-control field" placeholder="Your Email" name="email" required> | |
</div> | |
</div> | |
<div class="form-group"> | |
<div class="col-sm-12"> | |
<textarea class="form-control field" placeholder="Your Message" name="messageField" required></textarea> | |
</div> | |
</div> | |
<div class="form-group"> | |
<div class="col-sm-12"> | |
<button type="submit" class="btn btn-default">Send</button> | |
</div> | |
</div> | |
<div id="ok"> | |
Your message has been sent successfully. Thanks! | |
</div> | |
</form> | |
</div> <!--./col-md-8 --> | |
</div> <!--./row --> | |
</div> | |
</section> <!-- #/support --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#supportForm').bootstrapValidator({ | |
message: "That´s no valid!", | |
feedbackIcons: { | |
valid: 'glyphicon glyphicon-ok', | |
invalid: 'glyphicon glyphicon-remove', | |
validating: 'glyphicon glyphicon-refresh' | |
}, | |
fields: { | |
name: { | |
validators: { | |
notEmpty: { | |
message: "This field is mandatory and cannot be empty" | |
}, | |
} | |
}, | |
email: { | |
validators: { | |
notEmpty: { | |
message: "This field is mandatory and cannot be empty" | |
}, | |
emailAddress: { | |
message: "That doesn´t look like an e-mail address" | |
} | |
} | |
}, | |
messageField: { | |
validators: { | |
notEmpty: { | |
message: "The Message Cannot be empty!" | |
} | |
} | |
} | |
} | |
}).on('success.form.bv', function(e) { | |
e.preventDefault(); | |
var $form = $(e.target); | |
var bv = $form.data('bootstrapValidator'); | |
$.post($form.attr('action'), $form.serialize(), function(result) { | |
$('#ok').fadeIn(); | |
console.log(result); | |
}, 'json' ); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks Mr Juan from UDEMY