<?php

    define( "use_amp", false );

    include "library.php";


	$cxn = start_code( true );
	
    exit_if_search_bot();
	

    page_header( "", $cxn );


    
    $_SESSION['sender_name'] = val( $_POST, "sender_name" );

    $_SESSION['sender_phone_number'] = val( $_POST, "sender_phone_number" );

    $_SESSION['sender_email_address'] = val( $_POST, "sender_email_address" );

    $_SESSION['sender_message'] = val( $_POST, "sender_message" );


    $sender_name = val( $_POST, "sender_name" );

    $sender_phone_number = val( $_POST, "sender_phone_number" );

    $sender_email_address = val( $_POST, "sender_email_address" );

    $sender_message = val( $_POST, "sender_message" );

    
    $error_occured = false;
    
    echo "<br><br><br>";
    
    if ($sender_name == "")
    {
        $error_occured = true;
        
        echo red( "&nbsp;You must supply your name.<br><br>" );
    }
        
    if ($sender_phone_number == "" && $sender_email_address == "")
    {
        $error_occured = true;

        echo red( "&nbsp;You must supply either an email address or a phone number.<br>" );
    }
    
    if ($error_occured)
        echo "<br><br>&nbsp;<a href='/contact_us.php' class='glink'>Back to previous page</a><br><br>";
    else
    {
        $this_sender_message = str_replace( "\n", "<br>", $sender_message );
        
        $message = "Sender name: ".$sender_name."<br><br>Phone number: ".$sender_phone_number."<br><br>Email address: ".$sender_email_address."<br><br>Message:<br><br>".$this_sender_message."<br>";
        
        send_email( "Melbourne Paraplanning", "mark.mcilroy@outlook.com", "mark.mcilroy@outlook.com", "Melbourne Paraplanning", "mark.mcilroy@outlook.com", "MP Enquiry", $message, $message, $cxn, "live" );

        echo green( "<br>&nbsp;Message sent.<br><br>" );

        echo "<br>&nbsp;<a href='/' class='glink'>Back to home page</a><br><br>";
    }
    
?>