All pastes #164565 Raw Edit

Untitled

public text v1 · immutable
·published 2006-09-08 19:08 UTC
rendered paste body
<?php
// first we check for the confirmation box 
// bad result goes to the end of the script
if (isset($_POST['Confirmed'])) {


// build the array of empty fields or the message fields
$empty = $post = array();
foreach ($_POST as $Field => $Value) {
    if (empty($Value)) {
        $empty[$Field] = $Value;
    } else {
        $Msg[$Field] = $Value;
    }
}

// Function to build and send the message
function domsg() {
   $name=$_POST['Name'];
   $fromstore=$_POST['Store'];
   $to = "cg@natchezoffice.com";
   $subject = "Employee Data Input Form - $name";
   $headers = "From: ihop$fromstore@riverroadihops.com\r\n" .
       'X-Mailer: PHP-NatchezOffice_WWW/' . phpversion() . "\r\n";
   $MsgBody .="Employee Data Input Form\n\n";

    foreach ($Msg as $Field => $Value) {
    $MsgBody .= "$Field: $Value\n";
    }
$MsgBody = htmlspecialchars($MsgBody);
mail($to, $subject, $MsgBody, $headers);
// This lets the viewer know the form is emailed
print "<pre><center>";
print "<font face=\"Times New Roman, Serif\" size=\"6\" color=\"blue\">";
print "Thank you for submitting the form<br><br>";
print "Return to the <a href=\"http://www.natchezoffice.com\">home page</a>";
}

// If no empty fields build the email
if (empty($empty)) {
   domsg();
   
} else {

// found empty fields so print them out and make the user go back
print "<pre><center>";
print "<font face=\"Times New Roman, Serif\" size=\"6\" color=\"red\">";
print "<p align=\"center\">";
print "Please click \"Back\" and fill in the following fields before submitting<br><br>";
   foreach ($empty as $Field => $Value) {
   print "$Field\n";
   }
} 
} else {

// this prints out if the confirmation box wasn't checked
    print "<pre><center>";
    print "<font face=\"Times New Roman, Serif\" size=\"6\" color=\"red\">";
    print "You did not check the confirmation box at the bottom of the form.<br><br>";
    print "Please go back, confirm and check the box and resubmit";
} 


?>