Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 74131

Change value received on form submission

$
0
0

Below I will break out the code the best way that I can - I want to be able to receive a string emailed instead of a value number on my form submission.

Here is the section with the HTML:

<input type="checkbox" class="custom-control-input" id="rts1" name="rts[checked][]" value="1">

I have the following PHP code which I have not included the whole code:

    public function fill($data)
    {
        if (!is_array(($data))) {
            return;
        }
        $this->rtschecked = $data['rts']['checked']['0'];
    }

    public function process()
    {
        $email_vars = array(
            'rtschecked' => $this->get_rtschecked(),
        );

        if(isset($email_vars)) {
            foreach($email_vars as $k => $v) {
                $body = str_replace('{'.strtoupper($k).'}', $v, $body);
            }
        }

        $this->send($file, $body);
    }

    public function send($file, $body)
    {
        $mail = new PHPMailer();
        $mail->Mailer = 'mail';
    }

    public function get_rtschecked() {
        return $this->rtschecked;
    }

Email template:

Right to Opt-Out of Sale: {RTSCHECKED} <br>

Once I get an email, I receive the following result Right to Opt-Out of Sale: 1 if the checkbox is checked.

Is there a way to make it show 'Yes' on value = 1, and no if it is empty/no value?


Viewing all articles
Browse latest Browse all 74131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>