<?php

    include "library.php";

	$cxn = start_code( true );
	

    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>";
    
    if ($sender_name == "")
    {
        $error_occured = true;
        
        echo red( "You must supply your name.<br>" );
    }
        
    if ($sender_email_address == "")
    {
        $error_occured = true;

        echo red( "You must supply your email address.<br>" );
    }
    
    if ($error_occured)
        echo "<br><br><br><a href='contact_us.php'>Back to previous page</a><br><br>";
    else
    {
        $this_sender_message = str_replace( "\n", "<br>", $sender_message );
        
        $message = "Sender name: ".$sender_name."<br><br>Email address: ".$sender_email_address."<br><br>Message:<br><br>".$this_sender_message."<br>";
        
        send_email( "Philippines Businesses for Sale", "noreply@academicdating.net", "mark.mcilroy@outlook.com", "Academic Dating", "noreply@academicdating.net", "Enquiry", $message, $message, $cxn, "live" );

        echo darkgreen( "Message sent.<br><br><br>" );

        echo show_link( "Home Page", "/" );
    }
    
?>