<?php
	$name = $_POST['firstname'] . ' ' . $_POST['lastname'];
	$first = $_POST['first'];
	$last = $_POST['last'];
	$theMail = $_POST['email'];
	$msg = $name . " contacted you from " . $theMail . " regarding proofreading work.";
	
	if($_POST['firstname']=='')
	{		
		?>
		You should <a href="index.html">return</a> to my proofreading page, because
		<?php
			die(" you failed to enter data for your first name!");
	}
	if($_POST['lastname']=='')
	{
		?>
		You should <a href="index.html">return</a> to my proofreading page, because
		<?php
			die(" you failed to enter data for your last name!");
	}
	
	if($_POST['email']=='')
	{
		?>
		You should <a href="index.html">return</a> to my proofreading page, because
		<?php
			die(" you failed to enter an email address!");
	}
	
	echo "Hello $name! Your information was submitted. Thank you! You should hear back from the proofreader within the next 48 hours. ";
	echo "The proofreader will attempt to contact you at the following email address: " . $theMail;
	
	mail("kyrathasoft@gmail.com","Interested in obtaining proofreading", $msg, 'From:' . $theMail);
	
	$mysql_host = "######";
	$mysql_database = "######";
	$mysql_user = "######";
	$mysql_password = "######";
	$dbc = @mysqli_connect($mysql_host,$mysql_user,$mysql_password,$mysql_database)
		or die("Failed to connect to the database...");
	$query = "INSERT INTO proofreading_sought (firstname, lastname, email) " .
		"VALUES ($first, $last, $theMail)";
		
	if (!mysqli_query($query,$con))
    {
      die('Error: ' . mysql_error());
    }
    echo "Your data was successfully added to the database.";
		
	
	@mysqli_close($dbc);
	
	?>
	<center><a href="index.html">Return to proofreading page</a></center>
	<?php



?>