Send form without using PHP or similar

Asked

Viewed 4,210 times

3

I need my HTML FORM with Bootstrap sent. The problem is that I don’t know anything about PHP. The functionality I need is sending a message to an email address. Only the data and a message the customer wants to send. It will not go to any BD nor will it be used in another form. A traditional contact page.

Is there any way I can send my FORM without using a dynamic language?

  • 2

    Can you explain what you want to do with the form? IE, what is the use you want to give to the form data?

  • To submit the form you can use only HTML same, but to process the data sent you will need some programming language.

  • Paraphrasing what @Sergio said: Where do you want to send the form?

  • Depending on what you want to do you can use something like http:/jotformz.com, then you create and define a layout for the form and it stores and sends the data to you by email

  • The only way I know is by using a <b>mailto<b> as an action, where the form goes to the email address of the parameter. See that Forms need actions to make sense. It can be a simple javascript function, which shows an alert, anyway... I agree with @Sergio, the question is not clear.

3 answers

5

You can use the formspree.

No registration, no programming required back/front end. Just set some parameters in the form:

<form action="https://formspree.io/[email protected]" method="POST">
    <input type="text" name="mensagem">
    <input type="submit">Enviar</button>
</form>

The value after https://formspree.io/ is the email to which the form information will be sent.

To project page on Github shows some advanced options parameters that can be included in the form, to customize how it will be submitted to the recipient.

An example containing a predefined title and an email (chosen by the user) to which a reply should be sent:

<form action='https://formspree.io/[email protected]' method='post'>

  <!-- Título/Assunto do Email. -->
  <input type='hidden' name='_subject' value='Contato de Cliente'>

  <!-- Email de Resposta. -->
  <input type='email' name='_replyto' placeholder='Email p/ contato'>

  <!-- Mensagem que será submetida. -->
  <textarea name='mensagem'></textarea>

  <button type='submit'>Enviar</button>
</form>

4


To send an email form with only some programming language. In PHP it is very simple, look for the mail function();

Follow an example:

   <?php

       $para = "[email protected]"; 

       $nome = $_POST['ID_CAMPO_HTML_NOME']; //valor digitado no campo Nome
       $assunto = $_POST['ID_CAMPO_HTML_ASSUNTO']; //valor digitado no campo Assunto
       $mensagem = "<strong>Nome: </strong>".$nome; 
       $mensagem .= "<br> <strong>Mensagem:  
       </strong>".$_POST['ID_CAMPO_HTML_MENSAGEM']; //valor digitado no campo Mensagem


    //CODIFICAÇÕES CORRETAS PARA O FORMATO DO E-MAIL
       $headers = "Content-Type:text/html; charset=UTF-8\n";
       $headers .= "From: dominio.com.br<[email protected]>\n"; 
       $headers .= "X-Sender: <[email protected]>\n";
       $headers .= "X-Mailer: PHP v".phpversion()."\n"; 
       $headers .= "X-IP: ".$_SERVER['REMOTE_ADDR']."\n";
       $headers .= "Return-Path: <[email protected]>\n"; 
       $headers .= "MIME-Version: 1.0\n";

    mail($para, $assunto, $mensagem, $headers); 

    ?>

Use the "action" of the form, referencing to the PHP code

<form action="enviaEmail.php"> ...
  • Maurício, thanks for your answer and help. But PHP is still a bogeyman to me. I know it’s the most suitable language, but I still don’t feel comfortable using it. Anyway, thank you so much for your help.

  • Dispose! But I believe it is only possible to send email through some language, anyway I will be following the post, who knows someone does not give a more accessible solution...

  • Angelo, just the time you spent here saying that you are "afraid of php", if you had used this time to try to read and understand scripts php 2 lines of code, would have solved in 10 minutes or 4 hours.. No offense, but I think you need to hear one of these to get out of this "I don’t know, I’m afraid, I...". Got it? I hope a review like this can give you a push. Forward right.. rsrs

  • Daniel, Resolvido. It took a while, but it worked. Using the mail() that Mauricio sent and one day of searching, I was able to make it work. Still need to get the details right, for example, the message is falling in span. But at least it worked. Thank you very much for the help.

  • Good Angelo! It is not so difficult, is to research and understand how it works, good luck. Anything put there!

2

First of all, every language is dynamic.

What you probably meant is "language that runs on the server side".

A simple way to resolve your issue is to use HTML "mailto".

Example:

<a href='mailto:[email protected]?subject=Assunto&body=conteúdo'>Enviar email</a>

Example with <form>

<FORM Action="mailto:[email protected]?Subject=Assunto" METHOD="POST">
    mailto: protocol test:
    <br />Assunto 
    <INPUT name="Subject" value="Test Subject">
    <br  />Mensagem
    <TEXTAREA name="Body">
    lorem ipsum
    </TEXTAREA>
    <br />
    <INPUT type="submit" value="Submit"> 
</FORM>

Downside

User needs to have an email client installed and configured.

The vast majority of people don’t have it because they use Webmail or Messengers services like facebook messenger, twitter, Hotmail, yahoo, among others.

For Windows users, for example, the user will probably have Live Mail or Outlook Express on the screen, but without configuration. It will probably click to send and will be thinking that the message was actually sent. The same goes for any other operating systems.

Sending of forms services

Another way is to use third-party services. There are several services that provide a "action" URL for "<form>".

  • Daniel, I was interested in this third party service. How can I look for more? Do you have any to indicate? Thank you very much.

  • I recommend using the very script provided by bootstrap.. After all, the reason you want to avoid php or any other server side language is because you don’t know how to use it, right ? Currently any server of the most basic, has support php, mysql, etc.. Bootstrap comes with a sample, a very simple php script for sending email on the contact form.. That form is not enough for you?

  • Daniel, it would be perfect! I didn’t even know that the bootstrap already came with a script for this. .

Browser other questions tagged

You are not signed in. Login or sign up in order to post.