Hey guys,

so I have this issue. I need to make a contact form for my website... Here's the code for a really basic email form:
Code:
<?php 
if($_POST['submit']) {
	if(empty($_POST['name']) || empty($_POST['email']) || empty($_POST['comments'])) {
		$error = true;
	} else {
	
		$to = "mymail@yahoo.com";
		$name = trim($_POST['name']);
		$email = trim($_POST['email']);
		$comments = trim($_POST['comments']);
		
		$subject = "Contact Form";
		
		$messages = "Name: $name \r\n Email: $email \r\n Comments: $comments";
		$headers = "From:" . $name;
		$mailsent = mail($to, $subject, $messages, $headers);
		
		if($mailsent) {
			$sent = true;
		}
	}
}

?>


<!doctype html>
<html lang='en'>
<head> 
	<meta charset='utf-8'>
</head>
<body>
	<div id='wrapper'>
	<?php if($error == true) { ?>
	<p class='error'>Error</p>
	<?php } if ($sent == true) { ?>
	<p class='sent'>Message sent</p> 
	<?php } ?>
	<div id='contactform'>
		<form name='contact' action='<?php echo $_SERVER['PHP_SELF']; ?> method='post'>
			<label for='name'>Name:</label>
			<input type='text' name='name' />
			<label for='email'>Email:</label>
			<input type='email' name='email' />
			<label for='comments'>Comments:</label>
			<textarea name='comments'></textarea>
			<input type='submit' name='submit' class='submit' value='Submit' />
		</form>
	</div>
	</div>
</body>
</html>
But, when I upload the file to my test site and click the submit button, it doesn't work. In the current state I didn't even expect it to work, because there is no command for the submit button to do. I did it from a tutorial, because my php knowledge is still at 0

What do I have to do in order to have a functional emailing form?
Thanks