I am a Windows 7 user and I am creating a website on localhost:8080/ using XAMPP. I want to make a contact form using PHP for getting the data from the form(name, email, message) and sending them to my email. Here's what the form looks like in html so far:
<form class="contact-form" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" >
<br>
<input type="text" name="name" placeholder="Name">
<br><br>
<input type="email" name="email" placeholder="E-mail (required)" required>
<br><br>
<textarea name="message" placeholder="Type your message here..." rows="5" cols="30"></textarea>
<br><br>
<input type="submit" name="submit" value="Submit">
</form>
I am using the following PHP script:
<body>
<?php
$emailValidation = "";
if (filter_has_var(INPUT_POST, 'submit')) {
$email = $_POST['email'];
$name = $_POST['name'];
$message = $_POST['message'];
if (!empty($email) && !empty($name) && !empty($message)) {
} else {
}
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$emailValidation = "Invalid email format";
}
}
?>
.....stuff
</body>
When I submit the form the following error appears:
I have tried modifying the httpd-vhosts.conf file by adding the following lines:
<Directory "C:/xampp/htdocs/ColdBeatz-Site">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Allow from all
Require all granted
</Directory>
... but the problem remains!
NOTE: If I use a file (eg. contact.php) on action attribute, it is working fine!