Help with adding feature to a php script

I have this php script that works fine, but would like to add a feature to it, users select a driver to drop and a driver to add, the script will then send an email to the user that there driver change was successful, but would like to be able to also post what drivers they have dropped and which driver they have added, thx for any help, it is around line 231 that my respond part is

<?php require_once('Connections/fblank'); ?>
<?php
//initialize the session
if (!isset($_SESSION)) {
  session_start();
}

// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
  $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
  //to fully log out a visitor we need to clear the session varialbles
  $_SESSION['MM_Username'] = NULL;
  $_SESSION['MM_UserGroup'] = NULL;
  $_SESSION['PrevUrl'] = NULL;
  unset($_SESSION['MM_Username']);
  unset($_SESSION['MM_UserGroup']);
  unset($_SESSION['PrevUrl']);
    
  $logoutGoTo = "index.php";
  if ($logoutGoTo) {
    header("Location: $logoutGoTo");
    exit;
  }
}
?>
<?php
if (!isset($_SESSION)) {
  session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && true) { 
      $isValid = true; 
    } 
  } 
  return $isValid; 
}

$MM_restrictGoTo = "login_driverChange.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) 
  $MM_referrer .= "?" . $QUERY_STRING;
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$colname_getName = "-1";
if (isset($_SESSION['MM_Username'])) {
  $colname_getName = $_SESSION['MM_Username'];
}
mysql_select_db($database_fradmin, $fradmin);
$query_getName = sprintf("SELECT first_name, last_name, team_name FROM users WHERE username = %s", GetSQLValueString($colname_getName, "text"));
$getName = mysql_query($query_getName, $fradmin) or die(mysql_error());
$row_getName = mysql_fetch_assoc($getName);
$totalRows_getName = mysql_num_rows($getName);
?>

<?php
 /* Specify your SMTP Server, Port and Valid From Address */
  ini_set("SMTP","blank.com");
  ini_set("smtp_port","25");
  ini_set("sendmail_from","blank");

if (array_key_exists('send', $_POST)) {
  // mail processing script
  // remove escape characters from POST array
  if (PHP_VERSION < 6 && get_magic_quotes_gpc()) {
    function stripslashes_deep($value) {
      $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
      return $value;
    }
    $_POST = array_map('stripslashes_deep', $_POST);
  }

  $to = 'royfr@fantasyracein.com'; // use your own email address
  $subject = 'Driver Change Fantasyracein League';
  
  // list expected fields
  $expected = array('name', 'team', 'email', 'drop1', 'add1', 'drop2', 'add2', 'drop3', 'add3', 'drop4', 'add4', 'drop5', 'add5','drop6', 'add6');
  // set required fields
  $required = array('name', 'team', 'code', 'email');
  // create empty array for any missing fields
  $missing = array();

  // assume that there is nothing suspect
  $suspect = false;
  // create a pattern to locate suspect phrases
  $pattern = '/Content-Type:|Bcc:|Cc:/i';
  
  // function to check for suspect phrases
  function isSuspect($val, $pattern, &$suspect) {
    // if the variable is an array, loop through each element
    // and pass it recursively back to the same function
    if (is_array($val)) {
      foreach ($val as $item) {
         isSuspect($item, $pattern, $suspect);
      }
    } else {
      // if one of the suspect phrases is found, set Boolean to true
      if (preg_match($pattern, $val)) {
        $suspect = true;
      }
    }
  }

  // check the $_POST array and any subarrays for suspect content
  isSuspect($_POST, $pattern, $suspect);

  if ($suspect) {
    $mailSent = false;
    unset($missing);
  } else {
    // process the $_POST variables
    foreach ($_POST as $key => $value) {
      // assign to temporary variable and strip whitespace if not an array
      $temp = is_array($value) ? $value : trim($value);
      // if empty and required, add to $missing array
      if (empty($temp) && in_array($key, $required)) {
        array_push($missing, $key);
      } elseif (in_array($key, $expected)) {
        // otherwise, assign to a variable of the same name as $key
        ${$key} = $temp;
      }
    }
  }
  
  // validate the email address
  if (!empty($email)) {
    // regex to identify illegal characters in email address
    $checkEmail = '/^[^@]+@[^\\s\\r\
\\'";,@%]+$/';
    // reject the email address if it doesn't match
    if (!preg_match($checkEmail, $email)) {
      $suspect = true;
      $mailSent = false;
      unset($missing);
    }
  }

  
  // go ahead only if not suspect and all required fields OK
  if (!$suspect && empty($missing)) {
  
    // build the message
    $message = "Name: $name\\r\
\\r\
";
    $message .= "Team: $team\\r\
\\r\
";
    $message .= "Email: $email\\r\
\\r\
";
    $message .= "Drop Driver Group 1: $drop1\\r\
\\r\
";
    $message .= "Add Driver Group 1: $add1\\r\
\\r\
";
    $message .= "Drop Driver Group 2: $drop2\\r\
\\r\
";
    $message .= "Add Driver Group 2: $add2\\r\
\\r\
";
    $message .= "Drop Driver Group 3: $drop3\\r\
\\r\
";
    $message .= "Add Driver Group 3: $add3\\r\
\\r\
";
    $message .= "Drop Driver Group 4: $drop4\\r\
\\r\
";
    $message .= "Add Driver Group 4: $add4\\r\
\\r\
";
    $message .= "Drop Driver Group 5: $drop5\\r\
\\r\
";
    $message .= "Add Driver Group 5: $add5\\r\
\\r\
";
    $message .= "Drop Driver Group 6: $drop6\\r\
\\r\
";
    $message .= "Add Driver Group 6: $add6";

     // create additional headers
     $headers = "From: blank>\\r\
";
     $headers .= 'Content-Type: text/plain; charset=utf-8';
     if (!empty($email)) {
       $headers .= "\\r\
Reply-To: $email";
     }

      // auto respond script
        mail($_POST['email'], 'Fantasyracein League Admin',
"Thank you,\
" .$_POST['name'].',

Your driver change was successful. 
Fantasy Racing League Admin');

        // send it 
    $mailSent = mail($to, $subject, $message, $headers);
    if ($mailSent) {
      // $missing is no longer needed if the email is sent, so unset it
      unset($missing);
    }
  }
}
?>

RJweb,
Please use code tags when you post large amounts of code.
It’s the little hash button (pound for you I guess) in the top right hand corner of the editor.

thx for the tip, do I use # at beginning and ending

No probs :slight_smile:

You paste your code into the editor, highlight it, then hit the pound sign.
Alternatively, you can wrap it in [code] [/code] tags.

As far as I can tell, the variables you create, e.g. $drop1 etc, are going to have a value of what you have set as the value of the corresponding <input> field.
So for example

<input type="checkbox" name="drop1" value="drop" />

Will set variable $drop1 = “drop”; IF this checkbox is checked. Otherwise $drop1 will not have a value.