StartBootstrap / startbootstrap-clean-blog-jekyll

A Jekyll version of the Clean Blog theme by Start Bootstrap
https://startbootstrap.com/themes/clean-blog-jekyll/
MIT License
2.09k stars 2.68k forks source link

Using forms.brace.io for static contact form #10

Closed taraahmed closed 6 years ago

taraahmed commented 9 years ago

Hello,

I was trying to use forms.brace.io to get the contact form to work straight out of Github pages. It works.

The problem I am having is the messages are being relayed to my inbox, but the 'success' message after someone hits submit isn't actually a success message, It just displays the error/failure message which is written on numerous accounts in the JS validations.

Could someone please help me with why that is happening? If the message is successfully being sent, then why is the failure message coming up?

Thanks Tara

taraahmed commented 9 years ago

Here is the HTML form:

<form name="sentMessage" id="contactForm" novalidate>
    <div class="row control-group">
        <div class="form-group col-xs-12 floating-label-form-group controls">
            <label>Name</label>
            <input type="text" class="form-control" placeholder="Name" id="name" required data-validation-required-message="Please enter your name.">
            <p class="help-block text-danger"></p>
        </div>
    </div>
    <div class="row control-group">
        <div class="form-group col-xs-12 floating-label-form-group controls">
            <label>Email Address</label>
            <input type="email" class="form-control" placeholder="Email Address" id="email" required data-validation-required-message="Please enter your email address.">
            <p class="help-block text-danger"></p>
        </div>
    </div>
    <div class="row control-group">
        <div class="form-group col-xs-12 floating-label-form-group controls">
            <label>Phone Number</label>
            <input type="tel" class="form-control" placeholder="Phone Number" id="phone" required data-validation-required-message="Please enter your phone number.">
            <p class="help-block text-danger"></p>
        </div>
    </div>
    <div class="row control-group">
        <div class="form-group col-xs-12 floating-label-form-group controls">
            <label>Message</label>
            <textarea rows="5" class="form-control" placeholder="Message" id="message" required data-validation-required-message="Please enter a message."></textarea>
            <p class="help-block text-danger"></p>
        </div>
    </div>
    <br>
    <div id="success"></div>
    <div class="row">
        <div class="form-group col-xs-12">
            <button type="submit" class="btn btn-default">Send</button>
        </div>
    </div>
</form>

Here is the action- attribute:

action="http://forms.brace.io/hello@taraahmedme"
davidtmiller commented 9 years ago

Hmm, I don't have any experience using forms.brace.io, but if someone comes across this issue they might be able to help so I will keep it open for a while.

If you can't get this working, the PHP script included with the theme is a working form, and you just need to change your email address in the contact_me.php file and make sure your web server doesn't have any security settings blocking the form scripts.

jsheng08 commented 9 years ago

Quick fix for hosting static site on github

Hello, I not sure if you still need this. I used formspree instead the one you used. You will need to modify clean-blog.js and clean-blog.min.js ( minify again )

$.ajax({
                url: "././mail/contact_me.php",
                type: "POST",
                data: {
                    name: name,
                    phone: phone,
                    email: email,
                    message: message
                },
                cache: false,
                success: function() {

to something that looks like this

$.ajax({
                url: "//formspree.io/mail@jishengtan.me",
                type: "POST",
                data: {
                    name: name,
                    phone: phone,
                    email: email,
                    message: message
                },
                dataType: "json",
                cache: false,
                success: function() {

Things I did

Note: Github doesn't run php code at all.

davidtmiller commented 9 years ago

Thanks for this contribution! I am going to review it and see if I can get this working. I like this format better, especially since GitHub pages isn't going to be running the form well. Thanks!

davidtmiller commented 6 years ago

Added Formspree integration in place of the PHP file.