topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Friday March 29, 2024, 4:25 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: How to create a web FORM, with several questions, and get back email replies?  (Read 3296 times)

OptimalDesigns

  • Supporting Member
  • Joined in 2018
  • **
  • Posts: 68
  • (retired) Mathematical Engineer
    • View Profile
    • Calculus (level) Problem Solving; Examples & Compiler
    • Read more about this member.
    • Donate to Member
I've created a webpage with a Form that allows a user to select the class subjects they would be interested in a Zoom class.  How to have user do a submit and email me at [email protected] with subjects being 'class1', 'class2', 'class3', etc. for the various classes?

<form method="post" action="subscriberform.php" >
  <fieldset>
  <legend>Choose your <b>Class</b> interests</legend>
    <div class="row">
      <div class="column left">
        <input type="checkbox" id="class1" name="interest" value="class1">
        <label for="class1">Oil Refinery Optimization</label>
      </div>
      <div class="column right">
        <span>Crude oil comes in to an Oil Refinery and ... in processing oil?</span>
      </div>
    </div>

ooo ... 'n' various class subjects; how to email to each subject a user selects via checkbox?

    <div class="row">
      <div class="column left">
        <input type="checkbox" id="class'n'" name="interest" value="class'n'">
        <label for="class'n'">Calculus-level Coding</label>
      </div>
      <div class="column right">
        <span>Calculus-level Coding and ... ?</span>
      </div>
    </div>
    <div class="row">
      <button type="submit">Submit form</button>
    </div>
  </fieldset>
</form>

Emails rec'd could then be sorted by date or subject and sent replies when their class would meet.  Ideas?

Deozaan

  • Charter Member
  • Joined in 2006
  • ***
  • Points: 1
  • Posts: 9,747
    • View Profile
    • Read more about this member.
    • Donate to Member
Have you considered using Google Forms?

OptimalDesigns

  • Supporting Member
  • Joined in 2018
  • **
  • Posts: 68
  • (retired) Mathematical Engineer
    • View Profile
    • Calculus (level) Problem Solving; Examples & Compiler
    • Read more about this member.
    • Donate to Member
Tried it ... not enough form options.

Deozaan

  • Charter Member
  • Joined in 2006
  • ***
  • Points: 1
  • Posts: 9,747
    • View Profile
    • Read more about this member.
    • Donate to Member
In PHP you can use the mail function:

Code: PHP [Select]
  1. mail("[email protected]", $subject, $message);

If you need more control you can also manually set the email headers. More details here: https://www.w3school...p/func_mail_mail.asp

wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 11,186
    • View Profile
    • Donate to Member
If you're going to be doing this often, MachForm might be worth the investment for you.  I got it years ago, and still use it.

https://www.machform.com/

OptimalDesigns

  • Supporting Member
  • Joined in 2018
  • **
  • Posts: 68
  • (retired) Mathematical Engineer
    • View Profile
    • Calculus (level) Problem Solving; Examples & Compiler
    • Read more about this member.
    • Donate to Member
If you're going to be doing this often, MachForm might be worth the investment for you.  I got it years ago, and still use it.

https://www.machform.com/

Can one upload/import an html form?  Here is a link to my form ... https://goal-driven....om-math-classes.html .  I sent their support team a question on this import question, not sure when they'll get back to me.

Thanks for the lead!

wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 11,186
    • View Profile
    • Donate to Member
I've only ever used it to create forms from scratch in the application.

Shades

  • Member
  • Joined in 2006
  • **
  • Posts: 2,922
    • View Profile
    • Donate to Member
A crude, yet simple solution:

<p>Getting more information for class subject A, send a mail message using this <a href="mailto:youraddress@yourdomain.com?subject=Class%20subject%20A%20interest&amp;body=I,%20<sender;s%20name>%20have%20an%20interest%20in%2the%20following:%0AClass%20subject%20A%0A%0AKind%20regards,%0A<sender%20name>%0A">link</a>.</p>
<p>Getting more information for class subject B, send a mail message using this <a href="mailto:youraddress@yourdomain.com?subject=Class%20subject%20B%20interest&amp;body=I,%20<sender;s%20name>%20have%20an%20interest%20in%2the%20following:%0AClass%20subject%20B%0A%0AKind%20regards,%0A<sender%20name>%0A">link</a>.</p>
<p>Getting more information for class subject C, send a mail message using this <a href="mailto:youraddress@yourdomain.com?subject=Class%20subject%20C%20interest&amp;body=I,%20<sender;s%20name>%20have%20an%20interest%20in%2the%20following:%0AClass%20subject%20C%0A%0AKind%20regards,%0A<sender%20name>%0A">link</a>.</p>

<p>It is also possible to send a similar request by post using our <a href="www.yourdomain.com/contact"><strong>contact form</strong></a> or by using the telephone number(s) listed in the form.</p>

If people have a (properly configured) mail client on their system, they will see a new screen appear with all the required information already filled into the receivers address, the subject and the body of the message. The only thing the prospect needs to do is clicking on the 'Send' button of their respective mail client. If they have configured gmail or other online mail client, that should result in a new browser tab to their online mail account with the same message content already pre-filled.

Creating a message with an automated subject line and/or mail address are easy to filter in your own mail client (workable if attendance numbers are low) or mail processor (if attendance numbers are high). Most mail clients have features that can automate responses, if you wish to send the prospect a confirmation mail of any kind.

As stated earlier, it is a crude solution and only really viable for a low amount of classes in the current format. But you can alter the message content, etc. as you please.

This solution also does not take into account users that have an improperly configured mail client or no mail client at all on their system. Something to consider as well.

OptimalDesigns

  • Supporting Member
  • Joined in 2018
  • **
  • Posts: 68
  • (retired) Mathematical Engineer
    • View Profile
    • Calculus (level) Problem Solving; Examples & Compiler
    • Read more about this member.
    • Donate to Member
But, where is the logic to decide which checkboxes are checked?

Here is some php code I'm working on ...
<?php

if(isset($_POST['submit'&#93;) ){
  
if( empty($username) | empty($email) ) {
    print 
"Please go back and make sure that 'Name' and 'Email Address' fields have been filled out.";
    return 
false;
    }

use 
PHPMailer\PHPMailer\PHPMailer;
include_once 
"PHPMailer/PHPMailer.php";
include_once 
"PHPMailer/Exception.php";

// Define email variables
    
$mail->To "Classes <opt-designs&#64;goal-driven.net>";
    
$amail  $_POST['username'&#93;."<".$_POST['email'&#93;.">";
    
$mail->Headers "From&#58;".$amail."\r\n";
//    $mail->Headers .= 'Content-type&#58; text/html; charset=UTF-8';
    
$mail->isHTML(true);
    
$mail->Body " "

  
$classes $_POST['interest'&#93;;
  
if(empty($classes)) {
    echo(
"You didn't select any check boxes.");
    print 
"Please go back and make sure that at least one check box has been checked.";
    return 
false;
  }
  else 
  {
    foreach (
$classes as $value) {
      echo(
$value " ");     // testing!  $value="oil" ?
      
$mail->Subject $value;
      
send1();
     }
   }
  
clearAddresses();
}
<
script>
function 
send1()
   
$mail->send();
// Sending Email 
  
if( send() ) {
    print 
"Thank you, once 10+ sign-up for each topic, I will get back to you with a date and time for each class.<br>";
    return 
true;
    }
    else {
      print 
"An error occurred and your message could not be sent.";
      return 
false;
    }
</
script>

I'm new at PHP so need help here.  Following is one check box
        <input type="checkbox" id="oil" name="interest[]" value="oil">
        <label for="oil">Oil Refinery Optimization</label>
« Last Edit: July 11, 2020, 12:15 PM by OptimalDesigns, Reason: updating code »