I have 2 fields. Username, password and a submit button (send details). They're in an html form. I've included a .php file trying to change the action of the form to send an email to my own email address. After clicking the button on the page, it just shows a blank screen and opens the .php file. I don't know what I'm doing wrong.. seems really simple, but I can't get around to fix this and I've been messing for hours with the code. Both html and php are on different files.
HTML Code:
<p><form action="send_form_email.php" method="post">
Email:<br><input type="text" name="email">
Pass:<br><input type="text" name="pass">
<input type="submit" name="submit" value="Send Details">
</form></p>
PHP code:
<?php
if ($_SERVER['REQUEST_METHOD'] === "POST") {
if (empty($_POST['email'])) {
$emailError = 'Email is empty';
} else {
$email = $_POST['email'];
// validating the email
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$emailError = 'Invalid email';
}
}
if (empty($_POST['pass'])) {
$passError = 'Password is empty';
} else {
$pass = $_POST['pass'];
}
if (empty($emailError) && empty($messageError)) {
$headers = "From: Contact Form <myemail@live.com>" . "\r\n" .
"Reply-To: $email" . "\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-Type: text/html; charset=iso-8859-1\n";
}
}