Jump to content

Recommended Posts

Hi

 

I've inherited a form that sends the basic text email for output. I want to style this with html so the output forms into two columns in a table.  I can see how others have incorporated html into their php script, but can't work out how to do it for the coded forms I have.  See code below.

$diyf_today = date("jS F Y");
        $diyf_subject = "Staff and Student Room Booking Request";
    $diyf_feedback = "
    Student Number: $studentno \r\n
    School, College or Unit: $unit \r\n
    Name: $name \r\n
    Email: $email \r\n
    Phone: $phone \r\n
    Event: $event \r\n
    Event Description: $eventdesc \r\n
    Event Date: $eventdate \r\n
    Event Time: $eventtime \r\n
    Location: ".implode(', ', ${'location[]'})." \r\n
    If external location: \r\n
    - External Name of location: $extname \r\n
    - External Contact Person: $extperson \r\n
    - External Contact Email: $extemail \r\n
    - External IP Address:    $extIP \r\n \r\n
    Number Attending: Coffs $coffs; GC $gc; Lismore $lismore; NMSC $nmsc; THSS $thss; External $ext    \r\n
    Do you require videolink: $videolink \r\n
    Location of videolink:  $videolocation \r\n
    Do you require recording: $recorded \r\n
    Do you require additional AV equipment and support: $av \r\n
    - Type of equipment and support: $equip \r\n
    Do you require additional support: $support \r\n
    - Type of additional support: $support1 \r\n
    Additional Comments: $comment  ";    
    

        $diyf_mailTo = "luke.davis@scu.edu.au";
        $diyf_mailSubject = stripslashes($diyf_subject);
        $diyf_mailBody = stripslashes($diyf_feedback);
        $diyf_mailBody .= "\r\n\r\nThis Room Booking Request form was sent from the Student website on the $diyf_today \r\nReturn Email: $email";

        // Do not allow anything in here but valid emails, MUST pass through email validation, DO NOT put anything else in here!!!
        $diyf_mailHeader= "From: $email\r\n" . "Reply-To: $email\r\n" . "X-Mailer: PHP/" . phpversion();
        $diyf_mailHeaderToUser= "From: $diyf_mailTo\r\n" . "Reply-To: $diyf_mailTo\r\n" . "X-Mailer: PHP/" . phpversion();
        
        $sent = mail($diyf_mailTo,$diyf_mailSubject,$diyf_mailBody,$diyf_mailHeader);
        $returned = mail($email,$diyf_mailSubject,$diyf_mailBody,$diyf_mailHeaderToUser);

        if (!$sent || !$returned) {
            echo '<body><center><br><br><font face=verdana color="Gray">
                Sorry, There was a problem submiting your form.<br>
                Please use your browser\'s back button and re-submit the form.</font></center></body>';
        } else {
            echo ' ';// This gets around the PHP bug for self submitting forms submitting twice on redirect. stupid bugs 
            header("Location: $diyf_success_page");
        }
Edited by Ch0cu3r
Link to comment
https://forums.phpfreaks.com/topic/290295-html-layout-for-php-form/
Share on other sites

I see a bunch of code that is apparently the contents of your html form (php does not have forms).  So - why are you not adding the necessary 'table' html to this?  Isn't that what you want to do?

 

This chunk of code seems disjoint.  You prepare a form and then you send an email.  Odd stream of acitions.

No, this is the whole form. You didn't connect the above is the 'send' only bit to the email.

<?php

// *** This is really a temporary measure until we can get this turned into a websys module ***//
// Code is very ugly atm but is designed to be later broken up and with a nice GUI over it.


// The page to go to if form submission is successful
$diyf_success_page = 'http://scu.edu.au/students/index.php/166/';


// Any fields that are to be mandatory must be in here,
// 'field name' => 'text to display if not entered'
$diyf_mandatory = array('studentno' => 'Please provide your student number.',
                    'unit' => 'Please provide your school or unit name.',
                    'name' => 'Please provide your name.',
                    'email' => 'Please provide your email address.',
                    'phone' => 'Please provide your phone contact.',
                    'event' => 'Please provide name of event.',
                    'eventdesc' => 'Please provide event description.',
                    'eventdate' => 'Please provide event date.',
                   'eventtime' => 'Please provide event time.',
                   'videolink' => 'Please answer videolink requirement.',
                   'videolocation' => 'Please provide videolink location.',
                   'recorded' => 'Please answer recording requirement.',
                   'av' => 'Please provide additional av requirements.',
                   'equip' => 'Please provide description of additional equipment.',
                   'support' => 'Please provide additional support requirements.',
                   'support1' => 'Please provide description of additional support.',
                   'comment' => 'Please provide any additional comments.');
                   
// Any fields that require a valid email to be inserted
// 'field name' => 'text to display if not valid'

$diyf_email_fields = array('email' => 'Your email address is not valid.', 'extemail' => 'Your Email address provided for Video Conference Support person is invalid.');

//tab character
$tab = chr(9);



/**
 *  1. Insert the HTML for your form between <<<FORM_TEMPLATE  and FORM_TEMPLATE
 *
 *  2. For radio buttons:
 *     They must have their attributes in the following order,
 *        <input type="radio" name="..." value="..." +any other attributes...
 *       It will not work if anything is in the wrong order,
 *        e.g. <input type="radio" value="..." name="..."
 *     Will NOT work as the value and name attributes are in the wrong order
 *  
 *  3. All defualt select options must have an empty value
 *        e.g <option value="">Please select...</option>
 *            <option>Please select...</option> WILL NOT WORK
 */
$diyf_form = <<<FORM_TEMPLATE
 
<form action="" method="post" name="Room Booking Request" id="layout" enctype="multipart/form-data">

    <p><strong>ALL FIELDS ARE MANDATORY</strong></p>
    
    
    <p>
      <label for="studentno"><br>Student Number (if you are a staff member please type in 'staff'):
      <input name="studentno" type="text" id="studentno" size="8" maxlength="8"></label>
  </p>
    <p>
      <label for="unit">School/College/Unit:
        <br>
                  <input name="unit" type="text" id="unit" size="60"></label></p>

                  
        <p>
          <label for="name">Contact Name:
          <br>
<input name="name" type="text" id="name" size="60"></label>
         </p>
        
            <p><label for="email">Email: <br>
   <input name="email" type="text" id="email" size="22"></label>
   </p>
   
       <p><label for="phone">Phone:
       <br>
   <input name="phone" type="text" id="phone" size="22"></label>
   </p>
      <p>
  <label for="event"> Title of Event: <br>
           <input name="event" type="text" id="event" size="60"></label>
      </p>
            
<p>
  <label for="eventdesc"> Short Description of Event:<br>
    <textarea name="eventdesc" cols="60" rows="5" id="eventdesc"></textarea>
  </label>
</p>
              
         <p>
           <label for="eventdate">Date of Event:
             <input name="eventdate" type="text" id="eventdate"> </label>
          <label for="eventtime">    Time of Event:
            <input name="eventtime" type="text" id="eventtime"></label></p>

            
         <h3><br>
         Location:</h3>
         <p>Check all options that apply.<br> To select multiple chapters or networks - PC users hold down 'Ctrl' - Mac users hold down 'Apple' key.</p>
         
  <p><select name="location[]" size="6" multiple id="location" class="height">
                    <option value=""> Select Option/s </option>
      <option value="Coffs Harbour">Coffs Harbour (videolinked booking only)</option>
      <option value="Gold Coast">Gold Coast</option>
      <option value="Lismore">Lismore</option>
      <option value="National Marine Science Centre">National Marine Science Centre (NMSC) (videolinked booking only)</option>
      <option value="The Hotel School Sydney">The Hotel School Sydney (THSS) (videolinked booking only)</option>
       <option value="External Non-SCU">External Non-SCU</option>
                  </select>
           <br>
          <ul>    <strong>If external location:</strong>
           <br>
          <label for="extname">Name of Video Conference Support person at each external Non SCU location: <br>
           <input name="extname" type="text" id="extname" size="60"></label>
          
         <br> <label for="extperson">Video conference Support person phone number: <br>
           <input name="extperson" type="text" id="extperson" size="60"></label>
         
        <br> <label for="extemail">Email address of Video Conference Support person: <br>
           <input name="extemail" type="text" id="extemail" size="60"></label>

          <br> <label for="extIP">IP Address of External Site: <br>
           <input name="extIP" type="text" id="extIP" size="60"></label>
    </ul>   
  </p>
  <p>Number attending each location (if you are not using any of the below locations, please put a '0' in the field):</p>
  <p>
    <label for="coffs">Coffs Harbour:
      <input name="coffs" type="text" id="coffs" size="3" value="$coffs">
    </label>
    <label for="gc">Gold Coast:
      <input name="gc" type="text" id="gc" size="3" value="$gc">
    </label>
    <label for="lismore">Lismore:
      <input name="lismore" type="text" id="lismore" size="3" value="$lismore">
    </label>
    <label for="nmsc">NMSC:
      <input name="nmsc" type="text" id="nmsc" size="3" value="$nmsc">
    </label>
    <label for="thss">THSS:
      <input name="thss" type="text" id="thss" size="3" value="$thss">
    </label>
        <label for="ext">External:
      <input name="ext" type="text" id="ext" size="3" value="$ext">
    </label>
  </p>


<h3><br>
  Audio Visual Support and Equipment:</h3>

<p>Do you require videolink for this booking?<br>
(NB. Standard videolink support is connecting your videolink across campuses)<br>
<input type="radio" name="videolink" value="Yes"id="yes"  class="radioborder"><label for="yes">Yes</label>
        <input type="radio" name="videolink"  value="No"id="no" class="radioborder"><label for="no">No</label>

</p>

<p><label for="videolocation">Please indicate from which location/s videolink will be delivered:
  <br>
  <input name="videolocation" type="text" id="videolocation" size="60"></label></p>
</label>
</p>

<p>Do you require this event to be recorded (Mediasite - Teaching spaces only)?<br>
<input type="radio" name="recorded" value="Yes"id="yes1"  class="radioborder"><label for="yes">Yes</label>
        <input type="radio" name="recorded"  value="No"id="no1" class="radioborder"><label for="no">No</label>
</p>

<p>Do you require additional AV equipment and support? eg. portable microphones, audio recording, assistance for presenters.<br>
<input type="radio" name="av" value="Yes"id="yes2"  class="radioborder"><label for="yes">Yes</label>
        <input type="radio" name="av"  value="No"id="no2" class="radioborder"><label for="no">No</label><br><br>
    <label for="equip">Please indicate what equipment or support is required (if you have no requirements please type in 'none'):
           <br>
           <textarea name="equip" cols="60" rows="5" id="equip"></textarea>
    </label>    
</p>

<h3>Additional Support</h3>

<p>This support could incude furniture setup (for large events), additional tables, operable walls open between large rooms, dividers etc.
</p>

<p>Do you require additional support?<br>
<input type="radio" name="support" value="Yes"id="yes3"  class="radioborder"><label for="yes">Yes</label>
        <input type="radio" name="support"  value="No"id="no3" class="radioborder"><label for="no">No</label><br><br>
    <label for="support1">Please indicate what additional support is required (if you have no requirements please type in 'none'):
           <br>
           <textarea name="support1" cols="60" rows="5" id="support1"></textarea>
    </label>    
</p>
                    
  <p><label for="comment">Additional Comments (if you have no requirements please type in 'none'):<br>
          <textarea name="comment" cols="60" rows="5" id="comment"></textarea></label>
        </p>
<br>

<p><input name="Submit" type="submit" id="Submit" title="Submit Form" value="Submit Form"></p>
</form>

FORM_TEMPLATE;


//////////////////////////////////////////////////////////////////////////////////////
////////////////////            END FORM EDITING        //////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////


$diyf_fields       = array();
$diyf_selects      = array();
$diyf_checkboxes   = array();
$diyf_radio_groups = array();
$diyf_name_of_submit_button = '';

// get bits and put in template tags in value
parse_form($diyf_fields, $diyf_selects, $diyf_checkboxes, $diyf_radio_groups, $diyf_form, $diyf_name_of_submit_button);

/*** Get the post variables ***/
// IF A SELECT, put in array
foreach ($diyf_fields as $diyf_field) {
    if (in_array($diyf_field, $diyf_selects)) {
        if (!is_array(${$diyf_field})) {
            ${$diyf_field} = array();
        }
        // IF IS AN ARRAY LOOP THRU
        $field_stripped = str_replace(array(']','['), '', $diyf_field);
        if (is_array($_POST[$field_stripped])) {
            if (!empty($_POST[$field_stripped])) {
                foreach ($_POST[$field_stripped] as $arr_item) {
                    ${$diyf_field}[] = (empty($arr_item)) ? '' : htmlentities($arr_item);
                }
            }
        } else {
            ${$diyf_field}[] = (empty($_POST[$diyf_field])) ? '' : htmlentities($_POST[$diyf_field]);
        }
    } else {
        ${$diyf_field} = (empty($_POST[$diyf_field])) ? '' : htmlentities($_POST[$diyf_field]);
    }
}


// Replace [[name]] with actual values
foreach ($diyf_fields as $diyf_field) {
    if (!in_array($diyf_field, $diyf_selects)) {    
        $diyf_form = preg_replace("/\[\[$diyf_field\]\]/", ${$diyf_field}, $diyf_form);
    }
}

if (!isset($_POST[$diyf_name_of_submit_button])) { echo $diyf_form; } // First time huh?
else {
    // Check, tick and select the values already entered ----------
    // Selects
    foreach ($diyf_selects as $diyf_select) {
        // We'll have these in an array, loop through.
        if (!empty(${$diyf_select})) {
            foreach (${$diyf_select} as $diyf_sel) {
                if ($diyf_sel !== '') {
                    $diyf_form = preg_replace('/(<option\s*value="'.$diyf_sel.'")/is', '$1 selected', $diyf_form);
                }
            }
        }
    //    $diyf_form = preg_replace('/(<option\s*value="'.${$diyf_select}.'")/is', '$1 selected', $diyf_form);
//        $diyf_form = preg_replace('/(<option.*?[^>]*value\s*=\s*["\']\s*'.${$diyf_select}.'\s*["\'])/is', '$1 selected', $diyf_form);
    }
    // Radio buttons
    foreach ($diyf_radio_groups as $diyf_radio_group) {
        $diyf_form = preg_replace('/(name="'.$diyf_radio_group.'"\s*value="'.${$diyf_radio_group}.'")/is', '$1 checked', $diyf_form);
        $diyf_form = preg_replace('/(value="'.${$diyf_radio_group}.'"\s*name="'.$diyf_radio_group.'")/is', '$1 checked', $diyf_form);
    }
    
    // Checkboxes
    foreach ($diyf_checkboxes as $diyf_checkbox) {
        if (!empty(${$diyf_checkbox})) {
            
            $diyf_form = preg_replace('/(name\s*=\s*["\']\s*'.$diyf_checkbox.'\s*["\'])/', '$1 checked="checked"', $diyf_form);
        }
        
    }


    // Error check ---------------------------------------------
    $diyf_errors = '';
    //foreach ($diyf_mandatory as $diyf_field => $diyf_message) { if ((is_array(${$diyf_field}) && empty(${$diyf_field})) || trim(${$diyf_field}) == '') { $diyf_errors .= '<span class="error">'.$diyf_message.'</span><br />'; } }
    foreach ($diyf_mandatory as $diyf_field => $diyf_message) { if ((is_array(${$diyf_field}) && count(array_filter(${$diyf_field})) == 0) || (!is_array(${$diyf_field}) && trim(${$diyf_field}) == '')) { $diyf_errors .= '<span class="error">'.$diyf_message.'</span><br />'; } }
    foreach ($diyf_email_fields as $diyf_email_field => $diyf_message) { if (!empty(${$diyf_email_field}) && !preg_match('/^[a-zA-Z0-9\+_.-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$/', ${$diyf_email_field})) $diyf_errors .= '<span class="error">'.$diyf_message.'</span><br />'; }
    
    $attendanceNeedle = '[[PLACE]]';
    $attendanceError = '<span class="error">' . $attendanceNeedle . ' field must be a number only</span><br />';
    
    if (!isNumberOnly($coffs) && !empty($coffs)) {
        $diyf_errors = $diyf_errors . str_replace($attendanceNeedle, 'Coffs Harbour', $attendanceError);
    }
    if (!isNumberOnly($gc) && !empty($gc)) {
        $diyf_errors = $diyf_errors . str_replace($attendanceNeedle, 'Gold Coast', $attendanceError);
    }
    if (!isNumberOnly($lismore) && !empty($lismore)) {
        $diyf_errors = $diyf_errors . str_replace($attendanceNeedle, 'Lismore', $attendanceError);
    }
    if (!isNumberOnly($nmsc) && !empty($nmsc)) {
        $diyf_errors = $diyf_errors . str_replace($attendanceNeedle, 'NMSC', $attendanceError);
    }
    if (!isNumberOnly($thss) && !empty($thss)) {
        $diyf_errors = $diyf_errors . str_replace($attendanceNeedle, 'THSS', $attendanceError);
    }
    if (!isNumberOnly($ext) && !empty($ext)) {
        $diyf_errors = $diyf_errors . str_replace($attendanceNeedle, 'External', $attendanceError);
    }

    if (!empty($diyf_errors)) echo $diyf_errors.$diyf_form;
    else {

//////////////////////////////////////////////////////////////////////////////////////
////////////////////        START EDITTABLE SECTION     //////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
    // What to do with form data if no errors were encountered
        $diyf_today = date("jS F Y");
        $diyf_subject = "Staff and Student Room Booking Request";
    $diyf_feedback = "<html>
    <body>
<table>
    <tr>
        <td>Student Number:</td><td>$studentno </td>
    </tr>
    <tr>
        <td>School, College or Unit:</td><td>$unit </td>
    </tr>
    <tr>
        <td>Name:</td><td>$name </td>
    </tr>
    <tr>
        <td>Email:</td><td>$email </td>
    </tr>
    <tr>
        <td>Phone:</td><td>$phone </td>
    </tr>
    <tr>
        <td>Event:</td><td>$event </td>
    </tr>
    <tr>
        <td>Event Description:</td><td>$eventdesc </td>
    </tr>
    <tr>
        <td>Event Date:</td><td>$eventdate </td>
    </tr>
    <tr>
        <td>Event Time:</td><td>$eventtime </td>
    </tr>
    <tr>
        <td>Location:</td><td>".implode(', ', ${'location[]'})." </td>
    </tr>
    <tr>
        <td>If external location: </td>
    </tr>
    <tr>
        <td>- External Name of location:</td><td>$extname </td>
    </tr>
    <tr>
        <td>- External Contact Person:</td><td>$extperson </td>
    </tr>
    <tr>
        <td>- External Contact Email:</td><td>$extemail </td>
    </tr>
    <tr>
        <td>- External IP Address:</td><td>$extIP </td>
    </tr>
    <tr>
        <td>Number Attending:</td><td>Coffs $coffs; GC $gc; Lismore $lismore; NMSC $nmsc; THSS $thss; External $ext    </td>
    </tr>
    <tr>
        <td>Do you require videolink:</td><td>$videolink </td>
    </tr>
    <tr>
        <td>Location of videolink:</td><td>$videolocation </td>
    </tr>
    <tr>
        <td>Do you require recording:</td><td>$recorded </td>
    </tr>
    <tr>
        <td>Do you require additional AV equipment and support:</td><td>$av </td>
    </tr>
    <tr>
        <td>- Type of equipment and support:</td><td>$equip </td>
    </tr>
    <tr>
        <td>Do you require additional support:</td><td>$support </td>
    </tr>
    <tr>
        <td>- Type of additional support:</td><td>$support1 </td>
    </tr>
    <tr>
        <td>Additional Comments:</td><td>$comment</td>
    </tr>
</table>
</body>
</html>
";
    

        $diyf_mailTo = "kim.axford@scu.edu.au";
        $diyf_mailSubject = stripslashes($diyf_subject);
        $diyf_mailBody = stripslashes($diyf_feedback);
        $diyf_mailBody .= "\r\n\r\nThis Room Booking Request form was sent from the Student website on the $diyf_today \r\nReturn Email: $email";

        // Do not allow anything in here but valid emails, MUST pass through email validation, DO NOT put anything else in here!!!
        $diyf_mailHeader .= "MIME-Version: 1.0\r\n";
        $diyf_mailHeader .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
        $diyf_mailHeader= "From: $email\r\n" . "Reply-To: $email\r\n" . "X-Mailer: PHP/" . phpversion();
        
        $diyf_mailHeaderToUser .= "MIME-Version: 1.0\r\n";
        $diyf_mailHeaderToUser .= "Content-type: text/html; charset=iso-8859-1\r\n";
        $diyf_mailHeaderToUser= "From: $diyf_mailTo\r\n" . "Reply-To: $diyf_mailTo\r\n" . "X-Mailer: PHP/" . phpversion();
        
        $sent = mail($diyf_mailTo,$diyf_mailSubject,$diyf_mailBody,$diyf_mailHeader);
        $returned = mail($email,$diyf_mailSubject,$diyf_mailBody,$diyf_mailHeaderToUser);

        if (!$sent || !$returned) {
            echo '<body><center><br><br><font face=verdana color="Gray">
                Sorry, There was a problem submiting your form.<br>
                Please use your browser\'s back button and re-submit the form.</font></center></body>';
        } else {
            echo ' ';// This gets around the PHP bug for self submitting forms submitting twice on redirect. stupid bugs 
            header("Location: $diyf_success_page");
        }


//////////////////////////////////////////////////////////////////////////////////////
////////////////////        END EDITTABLE SECTION       //////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
    }
}

function isNumberOnly($val) {
 return preg_match('!^[0-9]+$!', $val);
}

function parse_form(&$fields, &$selects, &$checkboxes, &$radio_groups, &$form, &$name_of_submit_button) {

    //* pull out all the tags we need and put into the arrays *//
    $tag_of_interest = array();
    preg_match_all(':(<input[^>]*>|<select[^>]*>|<form[^>]*>|<textarea[^>]*>.*?</textarea>):is', $form, $tag_of_interest);

    foreach ($tag_of_interest[1] as $tag) {

        $tag_type = '';
        $tag_name = '';
        $new_tag = '';
        $inner_matches = array();

        /* <FORM> */
        if (preg_match('/<form[^>]*>/is', $tag)) {
            // Replace action attribute,
            $new_tag = preg_replace('/action\s*=\s*[\'"](.*?)[\'"]/is', "action=\"$_SERVER[PHP_SELF]\"", $tag);

            // or put in an action attribute
            if ($new_tag == $tag) {
                $new_tag = preg_replace('/<form\s*/is', "<form action=\"$_SERVER[PHP_SELF]\" ", $tag);
            }

            $form = str_replace($tag, $new_tag, $form);

        /* <SELECT> */
        } else if (preg_match('/<select[^>]*>/is', $tag)) {

            preg_match('/name\s*=\s*[\'"](.*?)[\'"]/is', $tag, $inner_matches);
            $tag_name = $inner_matches[1];
            array_push($fields, $tag_name);
            array_push($selects, $tag_name);

        /* <TEXTAREA> */
        } else if (preg_match(':<textarea[^>]*>.*?</textarea>:is', $tag)) {

            preg_match('/name\s*=\s*[\'"](.*?)[\'"]/is', $tag, $inner_matches);
            $tag_name = $inner_matches[1];

            array_push($fields, $tag_name);
            $new_tag = preg_replace(':(<textarea[^>]*>).*?</textarea>:is', '$1[['.$tag_name.']]</textarea>', $tag);

            $form = str_replace($tag, $new_tag, $form);

        /* <INPUT */
        } else if (preg_match('/<input[^>]*>/is', $tag)) {

            preg_match('/type\s*=\s*[\'"](.*?)[\'"]/is', $tag, $inner_matches);
            $tag_type = $inner_matches[1];
            preg_match('/name\s*=\s*[\'"](.*?)[\'"]/is', $tag, $inner_matches);
            $tag_name = $inner_matches[1];

            /* TYPE="SUBMIT"> */
            if (preg_match('/submit/is', $tag_type)) {

                preg_match('/name\s*=\s*[\'"](.*?)[\'"]/is', $tag, $inner_matches);
                $name_of_submit_button = $inner_matches[1];

            /* TYPE="CHECKBOX"> */
            } else if (preg_match('/checkbox/is', $tag_type)) {

                array_push($fields, $tag_name);
                array_push($checkboxes, $tag_name);

            /* TYPE="RADIO"> */
            } else if (preg_match('/radio/is', $tag_type)) {

                if (!in_array($tag_name, $radio_groups)) {
                    array_push($fields, $tag_name);
                    array_push($radio_groups, $tag_name);
                }

            /* TYPE="TEXT"> */
            } else if (preg_match('/text/is', $tag_type)) {

                array_push($fields, $tag_name);

                $new_tag = preg_replace('/value\s*=\s*[\'"](.*?)[\'"]/is', 'value="[['.$tag_name.']]"', $tag);

                if ($new_tag == $tag) {
                    $new_tag = str_replace($inner_matches[0], $inner_matches[0].' value="[['.$tag_name.']]" ', $tag);
                }

                $form = str_replace($tag, $new_tag, $form);

            }

        }// End if INPUT

    } // End foreach

}
?>
Edited by Ch0cu3r

It looks exactly like the php form. It should be two clean columns, left with question, right with answer. See below what comes through in the email message.

 

Staff and Student Room Booking Request
To:
Room Bookings
<html>
        <body>
<table>
    <tr>
        <td>Student Number:</td><td>Staff member </td>
    </tr>
    <tr>
        <td>School, College or Unit:</td><td>ESE </td>
    </tr>
    <tr>
        <td>Name:</td><td>Kim </td>
    </tr>
    <tr>
        <td>Email:</td><td>testing@mmm.edu.au </td>
    </tr>
    <tr>
        <td>Phone:</td><td>39753455 </td>
    </tr>
    <tr>
        <td>Event:</td><td>Video Conference </td>
    </tr>
    <tr>
        <td>Event Description:</td><td>Science gathering </td>
    </tr>
    <tr>
        <td>Event Date:</td><td>01/01/2015 </td>
    </tr>
    <tr>
        <td>Event Time:</td><td>11am </td>
    </tr>
    <tr>
        <td>Location:</td><td>National Marine Science Centre </td>
    </tr>
    <tr>
        <td>If external location: </td>
    </tr>
    <tr>
        <td>- External Name of location:</td><td> </td>
    </tr>
    <tr>
        <td>- External Contact Person:</td><td> </td>
    </tr>
    <tr>
        <td>- External Contact Email:</td><td></td>
    </tr>
    <tr>
        <td>- External IP Address:</td><td> </td>
    </tr>
    <tr>
        <td>Number Attending:</td><td>Coffs 0; GC 0; Lismore 0; NMSC 1; THSS 0; External 0    </td>
    </tr>
    <tr>
        <td>Do you require videolink:</td><td>Yes </td>
    </tr>
    <tr>
        <td>Location of videolink:</td><td>NMSC </td>
    </tr>
    <tr>
        <td>Do you require recording:</td><td>Yes </td>
    </tr>
    <tr>
        <td>Do you require additional AV equipment and support:</td><td>No </td>
    </tr>
    <tr>
        <td>- Type of equipment and support:</td><td>none </td>
    </tr>
    <tr>
        <td>Do you require additional support:</td><td>No </td>
    </tr>
    <tr>
        <td>- Type of additional support:</td><td>none </td>
    </tr>
    <tr>
        <td>Additional Comments:</td><td>none</td>
    </tr>
</table>
</body>
</html>

This Room Booking Request form was sent from the Student website on the 6th August 2014 
Return Email: testing@mmm.edu.au
Edited by Ch0cu3r

Try removing all of the \r's from these lines so that there is only \n's

$diyf_mailHeader .= "MIME-Version: 1.0\r\n";
$diyf_mailHeader .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$diyf_mailHeader= "From: $email\r\n" . "Reply-To: $email\r\n" . "X-Mailer: PHP/" . phpversion();
        
$diyf_mailHeaderToUser .= "MIME-Version: 1.0\r\n";
$diyf_mailHeaderToUser .= "Content-type: text/html; charset=iso-8859-1\r\n";
$diyf_mailHeaderToUser= "From: $diyf_mailTo\r\n" . "Reply-To: $diyf_mailTo\r\n" . "X-Mailer: PHP/" . phpversion();

I'm assuming this is a linux system you are sending from.

Did the below as you suggested - but my email is still coming out as the previous post with all the html in it. I get the same in Outlook and Gmail so it doesn't seem to be related to the email client.

// Do not allow anything in here but valid emails, MUST pass through email validation, DO NOT put anything else in here!!!
        $diyf_mailHeader .= "MIME-Version: 1.0\n";
        $diyf_mailHeader .= "Content-Type: text/html; charset=ISO-8859-1\n";
        $diyf_mailHeader= "From: $email\n" . "Reply-To: $email\n" . "X-Mailer: PHP/" . phpversion();
        
        $diyf_mailHeaderToUser .= "MIME-Version: 1.0\n";
        $diyf_mailHeaderToUser .= "Content-type: text/html; charset=iso-8859-1\n";
        $diyf_mailHeaderToUser= "From: $diyf_mailTo\n" . "Reply-To: $diyf_mailTo\n" . "X-Mailer: PHP/" . phpversion();
Edited by Ch0cu3r
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.