Hello everyone. I was hoping some of your smarter then me people can help me with a project. I am learning HTML and other stuff with it such as Java, scrips, PHP etc. I am attempting to get this form to work for a website I am working on. however I am kind of stuck on how I can get the form to send. I will do my best to post the HTML of the form, and the code from the file dependencies. Bare with me and thanks for taking the time to teach me how to do this for next time. Essentially, i think I need to write a PHP file? However suggestions are welcome.
Here is my code from the actual HTML page. This is just the part of the pages code however I think its the most important as its my contact form it self.
<div class="form-group">
<input name="user_name" type="text" class="form-control" placeholder="Your Name">
</div>
<div class="form-group">
<input name="user_email" type="text" class="form-control" placeholder="Email Address">
</div>
<div class="form-group">
<input name="user_subject" type="text" class="form-control" placeholder="Subject">
</div>
</div>
</div>
<div class="col-md-6 col-sm-12">
<div class="block">
<div class="form-group-2">
<textarea name="user_message" class="form-control" rows="3" placeholder="Your Message"></textarea>
</div>
<button class="btn btn-default" type="submit">Send Message</button>
</div>
</div>
<div class="error" id="error">Sorry, we seemed to of caused a wipe. Please try again or email us directly.</div>
<div class="success" id="success">Message Sent!</div>
</form>
</div>
Furthermore, here is the code from the dependency file I have named script.js here is the code I have so far that ties to the form on my contact.html page from above.
$(’#contact-form’).validate({
rules: {
user_name: {
required: true,
minlength: 4
},
user_email: {
required: true,
email:true
},
user_subject: {
required: false,
},
user_message: {
required: true,
},
},
messages: {
user_name: {
required: “Come on, you have a name don’t you?”,
minlength: “Your name must consist of at least 2 characters”
},
user_email: {
required: “Please insert your email address”,
},
user_message: {
required: “Hmmm, your not following mechanics very well. what seems to be going on?”,
minlength: “Your name must consist of at least 2 characters”
},
},
submitHandler: function(form) {
$(form).ajaxSubmit({
type:"POST",
data: $(form).serialize(),
url:"sendmail.php",
success: function() {
$('#contact-form #success').fadeIn();
},
error: function() {
$('#contact-form #error').fadeIn();
}
});
}});
Now I was following a tutorial and wrote this best of my abilities and understanding. I think the issue is with the sendmail.php url. It seems to be calling a PHP file maybe? However I dont have this file. Or perhaps this was a placeholder for the tutorial? I think that’s the issue but have no idea how to write a PHP file for the script file to call to. Any suggestions? Again sorry for my poor code and describing this but any help would be awesome. Trying to learn.