Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6804975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:31:53+00:00 2026-05-26T19:31:53+00:00

I have tried doing the research through this site to correct the problem on

  • 0

I have tried doing the research through this site to correct the problem on my own, but I still can’t seem to get this form to call on multiple options chosen in the check boxes provided. The code is from an online form I downloaded. None of the other exact questions on here seem to be able to help me.

FULL FORM:

<form id='contactus' action='<?php echo $formproc->GetSelfScript(); ?>' method='post' enctype="multipart/form-data" accept-charset='UTF-8'>

<input type='hidden' name='submitted' id='submitted' value='1'/>
<input type='hidden' name='<?php echo $formproc->GetFormIDInputName(); ?>' value='<?php echo $formproc->GetFormIDInputValue(); ?>'/>
<input type='hidden'  class='spmhidip' name='<?php echo $formproc->GetSpamTrapInputName(); ?>' />


<fieldset >

<dl>
<dd>*Name (last, first) 
<input type="text" name="name" size="33" value='<?php echo $formproc->SafeDisplay('name') ?>'> 
  <span id='contactus_name_errorloc' class='error'></span>
</dd>
</dl>

<dl>
<dd>*Email Address <input type="text" name="email" size="35" value='<?php echo $formproc->SafeDisplay('email') ?>'>    <span id='contactus_email_errorloc' class='error'>    </span>
</dd></dl>

<dl>
<dd>*Construction Experience <input type="radio" name="construction_experience" id="construction_experience" value="Yes<?php echo $formproc->SafeDisplay('experience') ?>">Yes<input type="radio" name="construction_experience" id="construction_experience" value="No<?php echo $formproc->SafeDisplay('experience') ?>">No </dd></dl>

<dl>
<dd>*You must have valid drivers license, please select all that apply: <br />
<input type=checkbox name="valid_license[]" id="valid_licenseD" value="D<?php echo $formproc->SafeDisplay('valid_license') ?>">D license 
<input type=checkbox name="valid_license[]" id="valid_licenseG" value="G<?php echo $formproc->SafeDisplay('valid_license') ?>">G license 
<input type=checkbox name="valid_license[]" id="valid_licenseG2" value="G2<?php echo $formproc->SafeDisplay('valid_license') ?>">G2 license 
</dd></dl>

<p><strong>Enter additional comments in the space provided below:</strong></p>

 <dl>
<dd> <span id='contactus_message_errorloc' class='error'></span><textarea name="message" id="message" cols="60" rows="8"><?php echo $formproc->SafeDisplay('message') ?></textarea></dd></dl>

<dl>
<dd>*Resume (insert attachment) <input type="file" name="resume" id="resume" value="" size="30"> 
<div><span class='error'><?php echo $formproc->GetErrorMessage(); ?></span></div>
   <span id='contactus_photo_errorloc' class='error'></span>
</dd></dl>

<p style="padding-left:60px;"><input type="submit" class="button primary" value="Submit Application" />   <input type="reset" class="button primary" value="Clear Form" name"clear" />

</fieldset>
</form>

Here is the php that calls on the information:

`

require_once("class.phpmailer.php");

/*
Interface to Captcha handler
*/
class FG_CaptchaHandler
{
function Validate() { return false;}
function GetError(){ return '';}
}
/*
FGContactForm is a general purpose contact form class
It supports Captcha, HTML Emails, sending emails
conditionally, File atachments and more.
*/
class FGContactForm
{
var $receipients;
var $errors;
var $error_message;
var $name;
var $email;
var $message;
var $from_address;
var $form_random_key;
var $conditional_field;
var $arr_conditional_receipients;
var $fileupload_fields;
var $captcha_handler;

var $mailer;

function FGContactForm()
{
    $this->receipients = array();
    $this->errors = array();
    $this->form_random_key = 'HTgsjhartag';
    $this->conditional_field='';
    $this->arr_conditional_receipients=array();
    $this->fileupload_fields=array();

    $this->mailer = new PHPMailer();
    $this->mailer->CharSet = 'utf-8';
}

function EnableCaptcha($captcha_handler)
{
    $this->captcha_handler = $captcha_handler;
    session_start();
}

function AddRecipient($email,$name="")
{
    $this->mailer->AddAddress($email,$name);
}

function SetFromAddress($from)
{
    $this->from_address = $from;
}
function SetFormRandomKey($key)
{
    $this->form_random_key = $key;
}
function GetSpamTrapInputName()
{
    return 'sp'.md5('KHGdnbvsgst'.$this->GetKey());
}
function SafeDisplay($value_name)
{
    if(empty($_POST[$value_name]))
    {
        return'';
    }
    return htmlentities($_POST[$value_name]);
}
function GetFormIDInputName()
{
    $rand = md5('TygshRt'.$this->GetKey());

    $rand = substr($rand,0,20);
    return 'id'.$rand;
}


function GetFormIDInputValue()
{
    return md5('jhgahTsajhg'.$this->GetKey());
}

function SetConditionalField($field)
{
    $this->conditional_field = $field;
}
function AddConditionalReceipent($value,$email)
{
    $this->arr_conditional_receipients[$value] =  $email;
}

function AddFileUploadField($file_field_name,$accepted_types,$max_size)
{

    $this->fileupload_fields[] =
        array("name"=>$file_field_name,
        "file_types"=>$accepted_types,
        "maxsize"=>$max_size);
}

function ProcessForm()
{
    if(!isset($_POST['submitted']))
    {
       return false;
    }
    if(!$this->Validate())
    {
        $this->error_message = implode('<br/>',$this->errors);
        return false;
    }
    $this->CollectData();

    $ret = $this->SendFormSubmission();

    return $ret;
}

function RedirectToURL($url)
{
    header("Location: $url");
    exit;
}

function GetErrorMessage()
{
    return $this->error_message;
}
function GetSelfScript()
{
    return htmlentities($_SERVER['PHP_SELF']);
}

function GetName()
{
    return $this->name;
}
function GetEmail()
{
    return $this->email;
}
function GetMessage()
{
    return htmlentities($this->message,ENT_QUOTES,"UTF-8");
}

/*——– Private (Internal) Functions ——– */

function SendFormSubmission()
{
    $this->CollectConditionalReceipients();

    $this->mailer->CharSet = 'utf-8';

    $this->mailer->Subject = "Online Application from $this->name";

    $this->mailer->From = $this->GetFromAddress();

    $this->mailer->FromName = "thermosealinsulation.ca";

    $this->mailer->AddReplyTo($this->email);

    $message = $this->ComposeFormtoEmail();

    $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$message)));
    $this->mailer->AltBody = @html_entity_decode($textMsg,ENT_QUOTES,"UTF-8");
    $this->mailer->MsgHTML($message);

    $this->AttachFiles();

    if(!$this->mailer->Send())
    {
        $this->add_error("Failed sending email!");
        return false;
    }

    return true;
}

function CollectConditionalReceipients()
{
    if(count($this->arr_conditional_receipients)>0 &&
      !empty($this->conditional_field) &&
      !empty($_POST[$this->conditional_field]))
    {
        foreach($this->arr_conditional_receipients as $condn => $rec)
        {
            if(strcasecmp($condn,$_POST[$this->conditional_field])==0 &&
            !empty($rec))
            {
                $this->AddRecipient($rec);
            }
        }
    }
}

/*
Internal variables, that you donot want to appear in the email
Add those variables in this array.
*/
function IsInternalVariable($varname)
{
    $arr_interanl_vars = array('scaptcha',
                        'submitted',
                        $this->GetSpamTrapInputName(),
                        $this->GetFormIDInputName()
                        );
    if(in_array($varname,$arr_interanl_vars))
    {
        return true;
    }
    return false;
}

function FormSubmissionToMail()
{
$ret_str='';
foreach($_POST as $key=>$value)
{
    if(!$this->IsInternalVariable($key))
    {
        $value = htmlentities($value,ENT_QUOTES,"UTF-8");
        $value = nl2br($value);
        $key = ucfirst($key);

        // CHANGES BEGIN HERE.....
        // This loop looks over all the $_POST values. Need to isolate the `valid_licenses` and do something special with it.
        if ($key == "valid_license") {
           $value = implode(", ", $value);
           // Now $value will output as the comma-separated values list.
        }
        // CHANGES END HERE

        $ret_str .= "<div class='label'>$key :</div><div class='value'>$value </div>\n";
    }

}
foreach($this->fileupload_fields as $upload_field)
{
    $field_name = $upload_field["name"];
    if(!$this->IsFileUploaded($field_name))
    {
        continue;
    }        

    $filename = basename($_FILES[$field_name]['name']);

    $ret_str .= "";
}
return $ret_str;
}
function ExtraInfoToMail()
{
    $ret_str='';

    $ip = $_SERVER['REMOTE_ADDR'];
    $ret_str = "<div class='label'>IP address of the submitter:</div><div class='value'>$ip</div>\n";

    return $ret_str;
}

function GetMailStyle()
{
    $retstr = "\n<style>".
    "body,.label,.value { font-family:Arial,Verdana; } ".
    ".label {font-weight:bold; margin-top:5px; font-size:1.2em; color:#333;} ".
    ".value {margin-bottom:15px;font-size:1.2em;padding-left:20px;} ".
    "</style>\n";

    return $retstr;
}
function GetHTMLHeaderPart()
{
     $retstr = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">'."\n".
               '<html><head><title></title>'.
               '<meta http-equiv=Content-Type content="text/html; charset=utf-8">';
     $retstr .= $this->GetMailStyle();
     $retstr .= '</head><body>';
     return $retstr;
}
function GetHTMLFooterPart()
{
    $retstr ='</body></html>';
    return $retstr ;
}
 function ComposeFormtoEmail() 
{
    $header = $this->GetHTMLHeaderPart(); 
$formsubmission = $this->FormSubmissionToMail(); 
$extra_info = $this->ExtraInfoToMail(); 
$footer = $this->GetHTMLFooterPart(); 

$message = $header."<div class='label'>Job Application Submission From thermosealinsulation.ca: </div><p>$formsubmission</p><hr/>$extra_info".$footer; 

return $message; 
}

function AttachFiles()
{
    foreach($this->fileupload_fields as $upld_field)
    {
        $field_name = $upld_field["name"];
        if(!$this->IsFileUploaded($field_name))
        {
            continue;
        }

        $filename =basename($_FILES[$field_name]['name']);

        $this->mailer->AddAttachment($_FILES[$field_name]["tmp_name"],$filename);
    }
}

function GetFromAddress()
{
    if(!empty($this->from_address))
    {
        return $this->from_address;
    }

    $host = $_SERVER['SERVER_NAME'];

    $from ="nobody@$host";
    return $from;
}

function Validate()
{
    $ret = true;
    //security validations
    if(empty($_POST[$this->GetFormIDInputName()]) ||
      $_POST[$this->GetFormIDInputName()] != $this->GetFormIDInputValue() )
    {
        //The proper error is not given intentionally
        $this->add_error("Automated submission prevention: case 1 failed");
        $ret = false;
    }

    //This is a hidden input field. Humans won't fill this field.
    if(!empty($_POST[$this->GetSpamTrapInputName()]) )
    {
        //The proper error is not given intentionally
        $this->add_error("Automated submission prevention: case 2 failed");
        $ret = false;
    }

    //name validations
    if(empty($_POST['name']))
    {
        $this->add_error("Please provide your name");
        $ret = false;
    }
    else
    if(strlen($_POST['name'])>50)
    {
        $this->add_error("Name is too big!");
        $ret = false;
    }

    //email validations
    if(empty($_POST['email']))
    {
        $this->add_error("Please provide your email address");
        $ret = false;
    }
    else
    if(strlen($_POST['email'])>50)
    {
        $this->add_error("Email address is too big!");
        $ret = false;
    }
    else
    if(!$this->validate_email($_POST['email']))
    {
        $this->add_error("Please provide a valid email address");
        $ret = false;
    }

    //message validaions
    if(strlen($_POST['message'])>2048)
    {
        $this->add_error("Message is too big!");
        $ret = false;
    }

    //captcha validaions
    if(isset($this->captcha_handler))
    {
        if(!$this->captcha_handler->Validate())
        {
            $this->add_error($this->captcha_handler->GetError());
            $ret = false;
        }
    }
    //file upload validations
    if(!empty($this->fileupload_fields))
    {
     if(!$this->ValidateFileUploads())
     {
        $ret = false;
     }
    }
    return $ret;
}

function ValidateFileType($field_name,$valid_filetypes)
{
    $ret=true;
    $info = pathinfo($_FILES[$field_name]['name']);
    $extn = $info['extension'];
    $extn = strtolower($extn);

    $arr_valid_filetypes= explode(',',$valid_filetypes);
    if(!in_array($extn,$arr_valid_filetypes))
    {
        $this->add_error("Valid file types are: $valid_filetypes");
        $ret=false;
    }
    return $ret;
}

function ValidateFileSize($field_name,$max_size)
{
    $size_of_uploaded_file =
            $_FILES[$field_name]["size"]/1024;//size in KBs
    if($size_of_uploaded_file > $max_size)
    {
        $this->add_error("The file is too big. File size should be less than $max_size KB");
        return false;
    }
    return true;
}

function IsFileUploaded($field_name)
{
    if(empty($_FILES[$field_name]['name']))
    {
        return false;
    }
    if(!is_uploaded_file($_FILES[$field_name]['tmp_name']))
    {
        return false;
    }
    return true;
}
function ValidateFileUploads()
{
    $ret=true;
    foreach($this->fileupload_fields as $upld_field)
    {
        $field_name = $upld_field["name"];

        $valid_filetypes = $upld_field["file_types"];

        if(!$this->IsFileUploaded($field_name))
        {
            continue;
        }

        if($_FILES[$field_name]["error"] != 0)
        {
            $this->add_error("Error in file upload; Error code:".$_FILES[$field_name]["error"]);
            $ret=false;
        }

        if(!empty($valid_filetypes) &&
         !$this->ValidateFileType($field_name,$valid_filetypes))
        {
            $ret=false;
        }

        if(!empty($upld_field["maxsize"]) &&
        $upld_field["maxsize"]>0)
        {
            if(!$this->ValidateFileSize($field_name,$upld_field["maxsize"]))
            {
                $ret=false;
            }
        }

    }
    return $ret;
}

function StripSlashes($str)
{
    if(get_magic_quotes_gpc())
    {
        $str = stripslashes($str);
    }
    return $str;
}
/*
Sanitize() function removes any potential threat from the
data submitted. Prevents email injections or any other hacker attempts.
if $remove_nl is true, newline chracters are removed from the input.
*/
function Sanitize($str,$remove_nl=true)
{
    $str = $this->StripSlashes($str);

    if($remove_nl)
    {
        $injections = array('/(\n+)/i',
            '/(\r+)/i',
            '/(\t+)/i',
            '/(%0A+)/i',
            '/(%0D+)/i',
            '/(%08+)/i',
            '/(%09+)/i'
            );
        $str = preg_replace($injections,'',$str);
    }

    return $str;
}

/*Collects clean data from the $_POST array and keeps in internal variables.*/
function CollectData()
{
    $this->name = $this->Sanitize($_POST['name']);
    $this->email = $this->Sanitize($_POST['email']);
    $this->ConstructionExperience = $this->Sanitize($_POST['ConstructionExperience']);
    foreach ($_POST['valid_license'] as $license) {
// Append each sanitized element onto valid_license[]
    $this->valid_license[] = $this->Sanitize($license) ;
}

    /*newline is OK in the message.*/
    $this->message = $this->StripSlashes($_POST['message']);
}

function add_error($error)
{
    array_push($this->errors,$error);
}
function validate_email($email)
{
    return eregi("^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$", $email);
}

function GetKey()
{
    return $this->form_random_key.$_SERVER['SERVER_NAME'].$_SERVER['REMOTE_ADDR'];
}

}

?>`

All the form returns is one option selected, even if multiple boxes are checked.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:31:53+00:00Added an answer on May 26, 2026 at 7:31 pm

    To allow multiple checkbox values, you must add [] to the name attribute. PHP will then treat it as an array:

    <input type=checkbox name="valid_license[]" id="valid_license" ... />
    

    Then be sure to process them as an array. Your $this->valid_license becomes an array as well.

    // Something like
    foreach ($_POST['valid_license'] as $license) {
      // Append each sanitized element onto valid_license[]
      $this->valid_license[] = $this->Sanitize($license);
    }
    

    Note, that you must supply different id= attributes to each one. The HTML spec requires than id attributes be unique. Right now, all of yours have id='valid_license'. Change them to id='valid_license1' or similar.

    Update (modifying function)

    function ComposeFormtoEmail() {
      $header = $this->GetHTMLHeaderPart(); 
      $formsubmission = $this->FormSubmissionToMail(); 
      $extra_info = $this->ExtraInfoToMail(); 
      $footer = $this->GetHTMLFooterPart(); 
    
      // Assign this to a variable
      $licenses = implode(", ", $this->valid_license); 
    
      // Then insert that variable into `$message`
      $message = $header."Job Application Submission From thermosealinsulation.ca :<p>$licenses</p><p>$formsubmission</p><hr/>$extra_info".$footer; 
      //---------------------------------------------------------------------------^^^^^^^^^^^^^^^^
    
      return $message; 
    }
    

    Update 2 The FormSubmissionToMail() function

    Ok, I think I finally get it. The fields and their headings are produced by FormSubmissionToMail(). So that’s where you need to add the implode() call, rather than in the ComposeFormToEmail() function as we did earlier:

    function FormSubmissionToMail()
    {
        $ret_str='';
        foreach($_POST as $key=>$value)
        {
            if(!$this->IsInternalVariable($key))
            {
                // MOVED THIS BLOCK FROM BELOW...
                // CHANGES BEGIN HERE.....
                // This loop looks over all the $_POST values. Need to isolate the `valid_licenses` and do something special with it.
                if ($key == "valid_license") {
                   $value = implode(", ", $value);
                   // Now $value will output as the comma-separated values list.
                }
                // CHANGES END HERE
    
                $value = htmlentities($value,ENT_QUOTES,"UTF-8");
                $value = nl2br($value);
                $key = ucfirst($key);
    
                $ret_str .= "<div class='label'>$key :</div><div class='value'>$value </div>\n";
            }
    
        }
        foreach($this->fileupload_fields as $upload_field)
        {
            $field_name = $upload_field["name"];
            if(!$this->IsFileUploaded($field_name))
            {
                continue;
            }        
    
            $filename = basename($_FILES[$field_name]['name']);
    
            $ret_str .= "<div class='label'>File upload '$field_name' :</div><div class='value'>$filename </div>\n";
        }
        return $ret_str;
    }
    
    ### Now that this is the correct location, go back and remove the changes we made to `ComposeFormToEmail()`
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I havent found info on this subject yet, but maybe someone have tried doing
I have tried this... Dim myMatches As String() = System.Text.RegularExpressions.Regex.Split(postRow.Item(Post), \b\#\b) But it is
I've been doing pages and pages of research and have tried a number of
I am doing some research on a asp.net bug. I tried to get adplus
I have two tables: Contestant and Votes Contestant hasMany Votes I've tried doing a
I have tried to integrate the Picasa API on iPhone, compiles fine, but I
I have tried to find how to create DLL-s on linux using google, but
I have tried different examples to filter a gridview by dropdownlist, but is it
Tried doing a bit of research on the following with no luck. Thought I'd
have been working and wearing out my fingers doing google searches with this one:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.