2

<div class="card-body">
  <form action="mailto:example@gmail.com" method="GET">
    <!-- Header -->
    <div class="form-header bg-secondary">
      <h3 class="mt-2"><i class="fa fa-envelope"></i> Let's Conect:</h3>
    </div>
    <!-- Body -->
    <div class="md-form"> <i class="fa fa-user-circle-o prefix grey-text"></i>
      <input type="text" id="form-name" placeholder="Your Name" class="form-control">
      <label for="form-name"></label>
    </div>
    <div class="md-form"> <i class="fa fa-envelope prefix grey-text"></i>
      <input type="text" id="form-email" placeholder="Your Email" class=" form-control">
      <label for="form-email"></label>
    </div>
    <div class="md-form"> <i class="fa fa-tag prefix grey-text"></i>
      <input type="text" id="form-Subject" placeholder="A Subject" class=" form-control">
      <label for="form-Subject"></label>
    </div>
    <div class="md-form"> <i class="fa fa-pencil prefix grey-text"></i>
      <textarea id="form-text" placeholder="What would you like to talk about!?" placeholder="class=" form-control md-textarea " rows="3 "></textarea>
        <label for="form-text "></label>
    </div>
    <div class="text-center ">
        <button type="submit " class="btn btn-secondary ">Submit</button>
    </div>
</form>
</div>

I've created a form using bootstrap 4. When I click submit it will pull up the email and send it to the email given in the action but does not capture and of the form data. I've tried enctype="text/plain" and using method="GET" and method="POST".

I've used a contact form im a similar fashion likes this:

<form id="contact-form" action="mailto:test@gmail.com" method="POST" enctype="text/plain">
    <label for="name">Name</label>
    <input type="text" id="name" name="Name" placeholder="Name" required="required">

    <label for="email">Email</label>
    <input type="email" id="email" name="E-Mail" placeholder="Email@gmail.com" required="required">

    <label for="subject">Subject</label>
    <input type="text" id="subject" name="Subject" required="required"></input>

    <label for="message">Message</label>
    <textarea id="message" name="Message" required="required"></textarea>

    <input type="submit" value="Submit">
    <input type="reset" value="Reset">
</form>

It would capture the form data as such:

Name=NAME
E-Mail=EMAIL@EMAIL.com
Subject=SUBJECT
Message=MESSAGE

and include it in the email. I'm looking to do this to avoid having to use a php if at all possible.

95faf8e76605e973
  • 13,643
  • 3
  • 24
  • 51
WasteOfADrumBum
  • 217
  • 2
  • 12
  • but does not capture and of the form data. - what that means? Are these 2 different forms? – gpl Aug 16 '20 at 06:46
  • So the 2nd form was the one that I was using that I just created myself. It works and captures the inputs and sends them in an email. The first form is what I've converted it to in order to use the Bootstrap CSS library and the form is not capturing the input values when sending the email. – WasteOfADrumBum Aug 16 '20 at 13:38

1 Answers1

0

Check this out:

<div class="card-body">
    <form action="mailto:example@gmail.com" method="get" enctype="text/plain">
        <!-- Header -->
        <div class="form-header bg-secondary">
            <h3 class="mt-2"><i class="fa fa-envelope"></i> Let's Conect:</h3>
        </div>
        
        <!-- Body -->
        <div class="md-form"> <i class="fa fa-tag prefix grey-text"></i>
            <input type="text" id="form-Subject" name="subject" placeholder="A Subject" class="form-control" required/>
            <label for="form-Subject"></label>
        </div>
        <div class="md-form"> <i class="fa fa-pencil prefix grey-text"></i>
            <textarea id="form-text" name="body" placeholder="What would you like to talk about!?"
            class="form-control md-textarea " rows="15" style="overflow-y: scroll;"></textarea>
            <label for="form-text"></label>
        </div>
        <div class="text-center">
            <input type="submit" name="submit" value="Submit" class="btn btn-secondary"/>
        </div>
    </form>
</div>

Seems you forget to add name attribute to your form-controls. Also haven't added enctype="text/plain" to the form and did some error in the message <textarea>.

Also this code is written in mdbootstrap which is based on bootstrap-5 not bootstrap-4

gpl
  • 1,380
  • 2
  • 8
  • 24
  • The form is now capturing the subject. However, it still doesn't retain the information from the name, email, or message. – WasteOfADrumBum Aug 18 '20 at 15:41
  • Please check it out again. – gpl Aug 18 '20 at 17:01
  • Copied it right into my HTML and still only pulled the subject and the mail to address, that was it. – WasteOfADrumBum Aug 18 '20 at 17:21
  • You have to share some more of your code. It runs fine in my browser. mailto forms are always cause this kid of mess. – gpl Aug 18 '20 at 17:55
  • I added a snippet of the entire section of code that has the contact form. – WasteOfADrumBum Aug 18 '20 at 18:39
  • https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css – WasteOfADrumBum Aug 18 '20 at 18:42
  • "https://code.jquery.com/jquery-3.5.1.js" "https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" "https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" That's all my style and script links – WasteOfADrumBum Aug 18 '20 at 18:43
  • I have used same things along with mdbootstrap 4.19.1. My bootstrap(both CSS n JS) version is 4.5.0. What is the purpose of this edit? You have to edit code provided by you in the question to help users. You must not edit code of an answer, unless are doing something useful with the answer. This is Stack Overflow guideline actually. – gpl Aug 19 '20 at 06:01
  • The mailto: is not for sending emails, instead it will create a mail with the receiver email specified in the mailto:example@gmail.com. Thus, we don't need user-name and email feilds. We already know those values. Now check this out this peice of code. It will work for you. I have added `style="overflow-y: scroll;"` to allow user to scroll long messages. – gpl Aug 19 '20 at 06:48