If statement on a columnsAndValues $_REQUEST

2 posts by 2 authors in: Forums > CMS Builder
Last Post: January 22, 2015   (RSS)

By Mikey - January 21, 2015

I need to apply an If statement on a columnsAndValues $_REQUEST. Below is my code. The goal is to allow the client the option of showing a field were they can request site visitors signing up for an event to indicate how many people will be coming to the event with them. I've bolded the areas that I need help with. I believe the first bold in green works as it is, but the other two in bold red are definitely giving me trouble.

<?php

$reminderErrorsAndAlerts = "";

// process reminder request
if (@$_REQUEST['submitNotificationForm']) {
  
  // error checking
  if (!@$_REQUEST['registrant_name'])  { $reminderErrorsAndAlerts .= "You Must Enter Your Name!<br/>"; }
  if (!@$_REQUEST['registrant_email'])  { $reminderErrorsAndAlerts .= "You Must Enter Your Email!<br/>"; }
  elseif (!isValidEmail($_REQUEST['registrant_email'])) { $reminderErrorsAndAlerts .= "You Must Enter A Vaild Email!<br/>"; }
  if (!@$_REQUEST['registrant_phone']) { $reminderErrorsAndAlerts .= "You Must Enter Your Phone Number!<br/>"; }
  
  // Show Event Reminder People Attending Field
  if ($eventsRecord['show_event_reminder_people_attending_field'] == '1') {
  if (!@$_REQUEST['number_of_people_accompanying_you']) { $reminderErrorsAndAlerts .= "You Must Enter The Number of People Accompanying You, Including Yourself!<br/>"; }
   } // End Show Event Reminder People Attending Field
  
  // add reminder request
  if (!$reminderErrorsAndAlerts) {
    
    $createdBy = @$CURRENT_USER['num']
       ? $CURRENT_USER['num']
       : 0
       ;
    
    $columnsAndValues = array ( 'event_name'             => $eventsRecord['num'],
'event_date'           => $eventsRecord['date'],
'event_summary'           => $eventsRecord['summary'], // added to test if info is delivered in message

'registrant_name'          => $_REQUEST['registrant_name'],
'registrant_email'         => $_REQUEST['registrant_email'],
'registrant_phone'         => $_REQUEST['registrant_phone'],
// Show Event Reminder People Attending Field
if ($eventsRecord['show_event_reminder_people_attending_field'] == '1') {
'number_of_people_accompanying_you' => $_REQUEST['number_of_people_accompanying_you'],
} // End Show Event Reminder People Attending Field
'registrant_remind_me'   => $_REQUEST['registrant_remind_me'],
'registrant_user_number'  => $createdBy,

'reminder_sent'                 => '0',
'dragSortOrder'        => time(),
'createdDate'          => date("y-m-d H:i:s", time()),
'createdByUserNum'     => $createdBy,
'updatedDate'          => date("y-m-d H:i:s", time()),
'updatedByUserNum'     => 0,
      );
  
    $newRecordNum = mysql_insert("event_signups", $columnsAndValues);
    
    // send confirmation email
    
$dateOfEvent =   date("Y-m-d", strtotime($eventsRecord['date']));
//$eventSummary =   $eventsRecord['summary'];
    
    
    $emailHeaders = emailTemplate_loadFromDB(array(
'template_id' => 'REMINDER-CONFIRMATION',
        'placeholders' => array(
'reminder.name' => $_REQUEST['registrant_name'],
'reminder.dateOfEvent' => $dateOfEvent,
'reminder.email' => $_REQUEST['registrant_email'],
'reminder.phone' => $_REQUEST['registrant_phone'],
// Show Event Reminder People Attending Field
if ($eventsRecord['show_event_reminder_people_attending_field'] == '1') {
'reminder.accompanying' => $_REQUEST['number_of_people_accompanying_you'],
} // End Show Event Reminder People Attending Field
'reminder.eventName' => $eventsRecord['title'], 
'reminder.eventSummary' => $eventsRecord['summary'], // added by Mike to test if info is delivered in message
          'reminder.numberOfDays'   => $_REQUEST['registrant_remind_me'],
         )
    ));
    $errors = sendMessage($emailHeaders);
    if ($errors) { alert("Mail Error: $errors"); }
    
    // clear form - let registrant know they've been signed up
    if ($newRecordNum) {
      $reminderErrorsAndAlerts = "Thanks! We've added your reminder request.<br />
You'll receive an email reminder ". $_REQUEST['registrant_remind_me'] ." days before your event";
      @$_REQUEST = array();
    }
    
  }

}


?>

Thanks for any help you can provide.

Zick