silexlabs / Silex

Silex live web creation, free/libre no-code website builder, next gen Webflow for the static web
http://www.silex.me
GNU Affero General Public License v3.0
2.21k stars 579 forks source link

Forms in Silex with formspree #442

Open lexoyo opened 8 years ago

lexoyo commented 8 years ago

Formspree is a nice tool to add forms to your Silex website.

Formspree is a commercial service, with a free and a paid plan.

How it works

When you add a form to your website, it looks like this

html-form-sample2

When a user submits info, Formspree will send you the info by email, it looks like this:

screenshot from 2016-07-20 13-11-54

Setting it up is easy and free

You don't even have to register.

Setup the HTML form

Copy this code and paste it in Silex, in an html box (insert menu then HTML Box, the double click on the HTML Box)

<form action="https://formspree.io/your@email.com"
      method="POST" target="_top">
    <input type="text" name="name">
    <input type="email" name="_replyto">
    <input type="submit" value="Send">
</form> 

Replace the email address (your@email.com) with your own email.

And add the fields you need in your form, for example you can add a dropdown list with a <select> HTML tag or another <input> HTML tag.

Ensure all <input>, <select> and <textarea> elements inside your form have a name attribute, otherwise you will not receive the data filled in these fields.

Submit the form and confirm your email address

Save your website, open the preview (view menu, then preview), and submit the form once. This will send you an email asking to confirm your email address.

Remember that if you display the same form in multiple URLs of your site you'll have to confirm it multiple times!

All set, receive emails

From now on, when someone submits that form, we'll forward you the data as email.

vatsalvala commented 7 years ago

can you give me example for dropdown option?

  <div class="input-field col s6">
    <select>
      <option value="91" selected>India (+91)</option>
      <option value="213">Algeria (+213)</option>
      <option value="376">Andorra (+376)</option>
      <option value="244">Angola (+244)</option>
      <option value="1264">Anguilla (+1264)</option>
      <option value="1268">Antigua &amp; Barbuda (+1268)</option>
      <option value="54">Argentina (+54)</option>
      <option value="374">Armenia (+374)</option>
    </select>
    <label>Country</label>
  </div>  

this dropdown coding selected value not shown in received email..

singchan commented 7 years ago

did you put this code between the <form action="https://formspree.io/your@email.com" method="POST" target="_top"> and the </form> ?

vatsalvala commented 7 years ago

@singchan yes, I have total 5 question i.e. name, mobile, email etc and also select country using dropdown menu but only dropdown result not shown in submitted form in received mail

singchan commented 7 years ago

oh ok you probably need to add a name="abcd" like this:

  <div class="input-field col s6">
    <select name="country">
      <option value="91" selected>India (+91)</option>
      <option value="213">Algeria (+213)</option>
vatsalvala commented 7 years ago

@singchan thanks man after submitting here, I also submit this problem to formspree and they teach me as you told.

Can I add "Bcc" mail? In formspree , only shown for "CC"

singchan commented 7 years ago

I think you can if you pay them? You can make a php file to receive the info and send emails with cc and data formated as you want

vatsalvala commented 7 years ago

@singchan : already "cc" is included in free plan thank you for reply

some noted that your site http://lexoyo.me/ is not support for mobile browser

btcsmartads commented 6 years ago

Can I add a captcha (e.g.: Coinhive PoW captcha) before submitting the form?

Is it possible to check if e-mail is an e-mail address? By default one can write any text in the field.

JbIPS commented 6 years ago

@btcsmartads I don't know about captcha but yes you can validate the form with JavaScript when the field value is changed (by listening to the DOM event)