<?php
	header('Content-Type: text/plain'); 
	if(isset($_POST)){
		if(isset($_POST['name'])) $name = $_POST['name'];
		if(isset($_POST['email'])) $email = $_POST['email'];
		if(isset($_POST['phone'])) $phone = $_POST['phone'];
		if(isset($_POST['message'])) $message = $_POST['message'];
		
		if(isset($_POST['site'])){
			$site = 'Выбранный сайт: '.$_POST['site'].'.';
		}
		if(isset($_POST['page'])){
			$page = 'Выбранные страницы:';
			foreach($_POST['page'] as $pages){
				$page .=', '.$pages;
			}
			$page .= '.';
			$page = str_replace(":, ",": ",$page);
		}
		
		$message .= "\r\n\r\n".$site."\r\n".$page;
		
		$url = "http://artbox.net.ua/en/feedback";
		$params = array(
			'name' 	=>	$name,
			'email'	=>	$email,
			'phone'	=>	$phone,
			'message'	=>	$message
		);
		$result = file_get_contents($url, false, stream_context_create(array(
			'http' => array(
				'method'	=>	'POST',
				'header'  => 'Content-type: application/x-www-form-urlencoded',
				'content' => http_build_query($params)
			)
		)));
	}