"New Song Suggestion/Request", 'TITLE' => "New Song Suggestion/Request", 'MODULENAME' => "newsong.phpx", 'NAV1' => "INFO" // Level 1 menu navigation group ); //------------------------------------------------------------------------ // Local configuration parameters //------------------------------------------------------------------------ global $SONGCFG; //------------------------------------------------------------------------ // Database Fields //------------------------------------------------------------------------ $ALLFIELD = array( 'song_title', 'song_artist', 'song_status', 'song_bpm', 'song_location', 'song_performer', 'song_year', 'youtube_url', 'song_notes', ); $NEWFIELD = array( 'song_title', 'song_artist', 'song_status', 'song_performer', 'song_year', 'youtube_url', 'song_notes', ); // Fields that are from a Menu Picklist that can have new members // $EXTEND = array( ); // // Required for New Entry // $RequiredField = array( 'song_title' => 'enter song name', ); // // Global query choices // $InValidChoice = array( 'All', '', ' ', 'None', 'Choose' ); $FieldType = array( 'song_artist' => 'LongText', 'song_title' => 'LongText', 'song_performer' => 'LongText', 'youtube_url' => 'LongText', 'song_notes' => 'TextArea' ); $BASE = "SELECT choice, description FROM menu WHERE table_name = 'song' AND "; $Menu = array( "gender" => "$BASE field_name = 'gender' ORDER BY choice", ); //------------------------------------------------------------------------ // BEGIN Program //------------------------------------------------------------------------ spew_header($FMT); // // Set default screen to entry form // if (!array_key_exists('Action', $_REQUEST)) { $_REQUEST['Action'] = 'New'; } if (array_key_exists('Action', $_REQUEST)) { //---------------------------------------------------------------------- // Submit Suggestion //---------------------------------------------------------------------- if ( $_REQUEST['Action'] == "Submit Suggestion" ) { $dbh = jjn_pdo_connect(); echo "
\n"; // DEVONLY echo "\n"; // DEVONLY $pcnt = count($_POST); $rcnt = count($_REQUEST); echo "
Submit Suggestion:\n"; // DEVONLY print_r($_REQUEST); // DEVONLY echo "
Request Count is greater that one, $rcnt
\n"; // DEVONLY echo "Post Count is greater that one, $pcnt
\n"; // DEVONLY echo "Session of captcha_keystring is $_SESSION[captcha_keystring]
\n"; // DEVONLY echo "Post of keystring is $_POST[keystring]
\n"; // DEVONLY echo "Request of keystring is $_REQUEST[keystring]
\n"; // DEVONLY // // CAPTCHA // if( count($_REQUEST) > 1 ){ if(isset($_SESSION['captcha_keystring']) && $_SESSION['captcha_keystring'] === $_REQUEST['keystring']){ echo "Excellent, you are a human!
"; }else{ echo "The numbers from the captcha box do match those in the image.";
echo "
Please press the back button and try again.\n";
echo "
No Data
"; spew_footer($FMT); exit; } // // Get list of fields for this table // $fieldlabel = get_field_labels('song','song',$JJNCFG['DBNAME']); $fields = array_keys($fieldlabel); $fieldlabel['song_notes'] = 'Types of Dances I Do to This Song'; // // Define default values // $Default = array ( 'song_status' => 'Suggested', ); echo "\n"; // DEVONLY echo "Default:\n"; // DEVONLY print_r($Default); // DEVONLY echo "\n"; // DEVONLY $NoEntry = array( ); // // Setup default values // foreach ($Default as $key => $val ) { if ( ! isset( $_REQUEST[$key]) ) { $_REQUEST[$key] = $val; echo "
Unsetting invalid entry for $f, $_REQUEST[$f]
\n"; // DEVONLY unset ($_REQUEST[$f]); } } // // Required fields gauntlet on input // foreach ( $RequiredField as $key => $val) { if (! array_key_exists($key, $_REQUEST)) { $err .= '";
echo "Please click the back button of the browser and ensure\n";
echo " all the information requested below is provided,\n";
echo " then fill out the captcha image field and hit Submit Suggestion\n";
echo " button at the bottom of the form.\n";
echo "
|
NewField Index: $f
\n"; // DEVONLY if ( array_key_exists($f, $_REQUEST)) { $val = $_REQUEST[$f]; if (isset($val)){ $Data[$f] = $dbh->quote($val); } } } echo "\n"; // DEVONLY echo "\n"; // DEVONLY //--------------------------------------- // INSERT Into Song //--------------------------------------- // $sql = "INSERT INTO song ("; $sql .= implode(', ', array_keys($Data) ); $sql .= ") VALUES ("; $sql .= implode(', ', array_values($Data) ); $sql .= ")"; echo "
Data:\n"; // DEVONLY print_r($Data); // DEVONLY echo "
$sql
\n"; // DEVONLY $dbh->query($sql); $_REQUEST['song_id'] = $song_id = $dbh->lastInsertId() ; echo "Returned Song ID of $_REQUEST[song_id]\n"; // DEVONLY echo "
\n";
echo "
|