<?php
if (isset($_POST['title'], $_POST['artist'], $_POST['link'] )) {                      
   $errors = array();  
   $title =   mysql_real_escape_string($_POST['title']);                
   $artist = mysql_real_escape_string($_POST['artist']);                
   $link = mysql_real_escape_string($_POST['link']);                
   $description = mysql_real_escape_string($_POST['description']);
    if (empty($title)) {                    
      $errors[] = '<strong>Song Title</strong> needs to be named'; 
    }                
    if (empty($artist)) {                   
      $errors[] = '<strong>Original Perfomer</strong> needs to be named';
    }                
    if (empty($link)) {         
      $errors[] = '<strong>Youtube-Link</strong> needs to be set';    
     }
     if (!empty($errors)) {     
       echo '<h4 style="margin-bottom: 20px; color: #c22336;">Your attention is required:</h4>';    
        foreach ($errors as $error) {   
           echo '<p style="margin-bottom: 20px;">', $error, '</p>';         
         }                    
           echo '<p style="margin-bottom: 20px;">Please fill out the blank field and send your nomination again.</p><hr />';               
       }               
       else {          
           echo '<h4 style="margin-bottom: 20px; color: #c22336">The song has been successfully nominated. Thank you...</h4>';
         // db connection                   
         include("xxx");
          
         $query = "INSERT INTO images (title, artist, link, description) VALUES ('".$title."', '".$artist."', '".$link."', '".$description."')";
          mysql_query($query) or die ('Ups, something went wrong. Please try again.');                }
}
?>