<?php
// process.php

$errors         = array();      // array to hold validation errors
$data           = array();      // array to pass back data

// validate the variables ======================================================
    // if any of these variables don't exist, add an error to our $errors array

    if (empty($_POST['nombre']))
        $errors['nombre'] = 'Name is required.';

    if (empty($_POST['email']))
        $errors['email'] = 'Email is required.';

    if (empty($_POST['mensage']))
        $errors['mensage'] = 'Mensaje is required.';

// return a response ===========================================================

    // if there are any errors in our errors array, return a success boolean of false
    if ( ! empty($errors)) {

        // if there are items in our errors array, return those errors
        $data['success'] = false;
        $data['errors']  = $errors;
    } else {

        // if there are no errors process our form, then return a message

        // DO ALL YOUR FORM PROCESSING HERE
        // THIS CAN BE WHATEVER YOU WANT TO DO (LOGIN, SAVE, UPDATE, WHATEVER)

        // show a message of success and provide a true success variable
        $nombre = $_POST['nombre']; 
    	$mail = $_POST['email'];
    	$msg = $_POST['mensage'];
    	$headers = 'From: ' . $mail . "\r\n" .
    			   'Reply-To: ' . $mail . "\r\n" .
    			   'X-Mailer: PHP/' . phpversion();
    	mail('6coloquio@cmat.edu.uy', 'Contacto de ' . $nombre, $msg, $headers);

        $data['success'] = true;
        $data['message'] = 'Mensaje enviado,<br/>A la brevedad el comite organizador se pondrĂ¡ en contacto con usted.';
        
    }

    // return all our data to an AJAX call
    echo json_encode($data);

?>