I have no idea how php works. Im using JavaScript for every logic but its only for client use and php is for server i think. Im getting a 405 (Method Not Allowed) error.
How can i send a email (Example: "example@gmail.com") to myself with the input data from a html form?
//** IF u need it **
// Working Contact Form
$('#contact-form').submit(function() {
var action = $(this).attr('action');
$("#message").slideUp(750, function() {
$('#message').hide();
$('#submit').before('').attr('disabled', 'disabled');
$.post(action, {
name: $('#name').val(),
email: $('#email').val(),
comments: $('#comments').val(),
},
function(data) {
document.getElementById('message').innerHTML = data;
$('#message').slideDown('slow');
$('#cform img.contact-loader').fadeOut('slow', function() {
$(this).remove()
});
$('#submit').removeAttr('disabled');
if (data.match('success') != null) $('#cform').slideUp('slow');
}
);
});
return false;
});
// Example starter JavaScript for disabling form submissions if there are invalid fields
(function() {
'use strict'
window.addEventListener('load', function() {
// Fetch all the forms we want to apply custom Bootstrap validation styles to
var forms = document.getElementsByClassName('needs-validation')
// Loop over them and prevent submission
Array.prototype.filter.call(forms, function(form) {
form.addEventListener('submit', function(event) {
console.log("test")
if (form.checkValidity() === false) {
event.preventDefault()
event.stopPropagation()
}
form.classList.add('was-validated')
}, false)
})
}, false)
}())
//Ignore CSS, doesnt matter
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form method="post" action="php/contact.php" name="contact-form" id="contact-form">
<div class="row">
<div class="col-lg-6">
<div class="row">
<div class="col-lg-12 col-md-6">
<div class="form-group">
<input name="name" id="name" type="text" class="form-control border rounded" placeholder="Name :">
</div>
</div>
<!--end col-->
<div class="col-lg-12 col-md-6">
<div class="form-group">
<input name="email" id="email" type="email" class="form-control border rounded" placeholder="Email :">
</div>
</div>
<!--end col-->
<div class="col-lg-12">
<div class="form-group">
<input name="subject" id="subject" class="form-control border rounded" placeholder="Betreff :">
</div>
</div>
<!--end col-->
</div>
<!--end row-->
</div>
<!--end col-->
<div class="col-lg-6">
<div class="form-group">
<textarea name="comments" id="comments" rows="4" class="form-control border rounded" placeholder="Nachricht :"></textarea>
</div>
</div>
<!--end col-->
</div>
<!--end row-->
<div class="row">
<div class="col-sm-12 text-right">
<input type="submit" id="submit" name="send" class="submitBnt btn btn-pill btn-custom" value="Senden">
<div id="simple-msg"></div>
</div>
<!--end col-->
</div>
<!--end row-->
</form>
<!--end form-->
Im using VS-Code with LiveServer extension to create a website. Can i use php there or what is the problem? Btw, still have a problem with JS i think..?!
If anybody know how to help, please comment! Thank you.