8 Replies Latest reply: Oct 5, 2014 7:09 AM by Rob Hecker2 RSS

    Submitting form to database, and sending email with one button

    Max Resnikoff Community Member

      Hi,

       

      Can someone help me to write a script, which will allow me to insert the forms data into the MySQL database, and send a confirmation email?

       

      I have tried to look this up, but I can't seem to find anything like this.

       

      Any help would be very much appreciated!

       

      Thank you!

        • 2. Re: Submitting form to database, and sending email with one button
          Max Resnikoff Community Member

          I know how to insert data, but i dont know how to send an email at the same time as inserting data!

          • 3. Re: Submitting form to database, and sending email with one button
            Nancy O. CommunityMVP

            What logic are you using?  What code have you got so far?

             

             

            Nancy O.

            • 5. Re: Submitting form to database, and sending email with one button
              Max Resnikoff Community Member

              To insert the record, I am using the default dreamweaver server behaviours. But i am unsure as to how to send an email along with the submission.

              • 6. Re: Submitting form to database, and sending email with one button
                Nancy O. CommunityMVP

                Those deprecated Server Behaviors are very limited in scope.  You'll need to rely less on Behaviors and learn to manually code.

                 

                 

                Nancy O.

                • 7. Re: Submitting form to database, and sending email with one button
                  Max Resnikoff Community Member

                  This is what I have at the moment: (Im not sure where to go from here)

                   

                  This is what I have at the moment:

                   

                  <div class="main">

                  <div class="heading1">Contact Us</div>

                  <div class="heading2">Please fill out the form below, and we will get back to you as soon as possible!</div>

                    <div class="contactform">

                                   <div class="tableframe">

                                     <form action="?" method="POST" name="contactform" id="contactform">

                                <table width="100%" border="0" cellpadding="5">

                                        <tr>

                                           <td><div class="formtag">First Name</div>

                                             <span id="sprytextfield1">

                                             <label for="firstname"></label>

                                             <input class="textfieldcap" type="text" name="firstname" id="firstname" />

                                        <span class="textfieldRequiredMsg">Please enter you first name</span></span></td>

                                      </tr>

                                         <tr>

                                           <td><div class="formtag">Last Name</div>

                                             <span id="sprytextfield2">

                                             <label for="lastname"></label>

                                             <input class="textfieldcap" type="text" name="lastname" id="lastname" />

                                             <span class="textfieldRequiredMsg">Please enter you last name</span></span></td>

                                      </tr>

                                         <tr>

                                           <td><div class="formtag">Email</div>

                                             <span id="sprytextfield3">

                                          <label for="email"></label>

                                          <input class="textfield" type="text" name="email" id="email" />

                                        <span class="textfieldRequiredMsg">Please enter your email address</span><span class="textfieldInvalidFormatMsg">Please enter a valid email address</span></span></td>

                                      </tr>

                                         <tr>

                                           <td><div class="formtag">Verify Email</div>

                                             <span id="spryconfirm1">

                                             <label for="verifyemail"></label>

                                             <input class="textfield" type="text" name="verifyemail" id="verifyemail" />

                                        <span class="confirmRequiredMsg">Please verify your email</span><span class="confirmInvalidMsg">Your emails do not match</span></span></td>

                                      </tr>

                                         <tr>

                                           <td><div class="formtag">Mobile Number</div>

                                             <span id="sprytextfield4">

                                          <label for="mobilenumber"></label>

                                          <input class="textfield" type="text" name="mobilenumber" id="mobilenumber" />

                                        <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>

                                      </tr>

                                         <tr>

                                           <td><div class="formtag">Your Message</div>

                                             <span id="sprytextarea1">

                                          <label for="message"></label>

                                          <textarea class="textarea" name="message" id="message" cols="45" rows="5"></textarea>

                                        <span style="color:#FFF" id="countsprytextarea1"></span><span class="textareaMaxCharsMsg">Exceeded maximum number of characters.</span><span class="textareaRequiredMsg">Please enter your message</span></span></td>

                                      </tr>

                                         <tr>

                                           <td> </td>

                                      </tr>

                                         <tr>

                                           <td align="center"><input name="submit" type="submit" class="buttonform" id="submit" value="Send" /></td>

                                      </tr>

                                </table>

                             </form>

                            </div>

                          <br />

                        </div>

                     </div>

                  </div>

                  • 8. Re: Submitting form to database, and sending email with one button
                    Rob Hecker2 CommunityMVP

                    The code you provided is your form, but there needs to be code to process the form. The form is HTML, but the code to process it is going to be PHP. You can put the processing code on the top of the same script (page) as the form, or have the form send it to a different file. Right now, note that your form action is just a question mark. That needs to be changed to the file that will process the form.

                     

                    As for what should go in the form processing section, refer to the links Nancy provided.