title: How do I insert $data and $param into body of email
body: <p>I am not a programmer and using phprunner to create page to send an email to selected records.
  I have used some pre-existing code via this link
  <a href="https://phprunner.com/phprunner/docs/email_selected_users.htm" rel="nofollow noreferrer">https://phprunner.com/phprunner/docs/email_selected_users.htm</a>
  and a modification to it on stackoverflow (Thanks [Micheal.M][1]).  I need to input the 'from' 'subject' and 'body' via a form. The 'subject' and 'from' parts works fine.</p>
  <p>But how can I get the $params[&quot;emailBody&quot;] and the $data[&quot;FirstName&quot;] both to appear in the 'body' of the email?
  'FirstName' field is from a table called Students_ALL.</p>
  <p>Can someone please guide me? I have tried for two days and cannot figure it out. Please find the code below: THANK YOU SO MUCH in advance - Mayo</p>
  <p>SERVER</p>
  <pre><code>if( $params[&quot;emailBody&quot;] ||$params[&quot;emailSubject&quot;] || $params[&quot;emailFrom&quot;] )
  {
  $emails = array();
  
  while( $data = $button-&gt;getNextSelectedRecord() )
  {
      // Send only if email field not empty
      if( $data[&quot;Email1&quot;] ) {
          // This no longer should be an array of emails
                  $from = $params[&quot;emailFrom&quot;];
         $email = $data[&quot;Email1&quot;];
                  $subject = $params[&quot;emailSubject&quot;];
                  $body = $params [&quot;emailBody&quot;];
          // Email will be sent for each record
          $arr = runner_mail(array('to' =&gt; $email, 'subject' =&gt; $subject, 'from' =&gt; $from, 'htmlbody' =&gt; $body));
  }
  }
  
  $result[&quot;txt&quot;] = &quot;Emails were sent.&quot;;
  if (!$arr[&quot;mailed&quot;])
  {
  $errmsg = &quot;Error happened:
  &quot;;
  $errmsg.= &quot;File: &quot; . $arr[&quot;errors&quot;][0][&quot;file&quot;] . &quot;
  &quot;;
  $errmsg.= &quot;Line: &quot; . $arr[&quot;errors&quot;][0][&quot;line&quot;] . &quot;
  &quot;;
  $errmsg.= &quot;Description: &quot; . $arr[&quot;errors&quot;][0][&quot;description&quot;] . &quot;
  &quot;;
  $result[&quot;txt&quot;] = $errmsg;
  }
  }   
  </code></pre>
  <h2>CLIENT BEFORE</h2>
  <pre><code>if ( proxy[&quot;emailUsers&quot;] === true ) {  
     params[&quot;emailFrom&quot;] = proxy[&quot;emailFrom&quot;];
     params[&quot;emailBody&quot;] = proxy[&quot;emailBody&quot;];
     params[&quot;emailSubject&quot;] = proxy[&quot;emailSubject&quot;];
   
     proxy[&quot;emailUsers&quot;] = false;
    return true;
  }  
   
  var selBoxes = pageObj.getSelBoxes( pageid ),
     args = {
         modal: true,
         header: &quot;Input from, subject and body&quot;,
         html: '&lt;div&gt;'
            + '&lt;div&gt;From: &lt;input type=&quot;text&quot; id=&quot;emailFrom&quot;s style=&quot;margin: 5px 0&quot;&gt;&lt;/div&gt;'
            + '&lt;div&gt;Subject: &lt;input type=&quot;text&quot; id=&quot;emailSubject&quot;s style=&quot;margin: 5px 0&quot;&gt;&lt;/div&gt;'
            + '&lt;div&gt;Body: &lt;textarea id=&quot;emailBody&quot;&gt;&lt;/textarea&gt;&lt;/div&gt;'
            + '&lt;/div&gt;',
         footer: '&lt;a href=&quot;#&quot; id=&quot;emailUsersSave&quot; class=&quot;btn btn-primary&quot;&gt;' + Runner.lang.constants.TEXT_SAVE + '&lt;/a&gt;'
             + '&lt;a href=&quot;#&quot; id=&quot;emailUsersCancel&quot; class=&quot;btn btn-default&quot;&gt;' + Runner.lang.constants.TEXT_CANCEL + '&lt;/a&gt;',
         afterCreate: function( win ) {
            $(&quot;#emailUsersSave&quot;).on(&quot;click&quot;, function( e ) {
                var context = win.body();
   
                 proxy[&quot;emailUsers&quot;] = true;
                 proxy[&quot;emailFrom&quot;] = $(&quot;#emailFrom&quot;, context).val();
                 proxy[&quot;emailBody&quot;] = $(&quot;#emailBody&quot;, context).val();
                 proxy[&quot;emailSubject&quot;] = $(&quot;#emailSubject&quot;, context).val();
                $('[id=&quot;' + ctrl.id + '&quot;]').click();
   
                 e.preventDefault();              
                 win.destroy();
             });
   
            $(&quot;#emailUsersCancel&quot;).on(&quot;click&quot;, function( e ) {
                 e.preventDefault();
                 win.destroy();                        
             });        
         }
     };
   
  if ( selBoxes.length == 0 || !confirm('Do you really want to email these records?') ) {
    return false;
  }
   
  Runner.displayPopup( args );
  return false;
  </code></pre>
  <h2>CLIENT AFTER</h2>
  <pre><code>var message = result[&quot;txt&quot;] + &quot; !!!&quot;;
  ctrl.setMessage(message);
  
   [1]: https://stackoverflow.com/users/2432106/michal-m
  </code></pre>