I build a website which has a form. Contact form redirects to contact.php on submit. For some reason whenever I submit, it says page not found.
index.html
...
<form action="contact.php" method="post" enctype="text/plain">
Name:<br>
<input type="text" name="name" class="form-control" required><br>
E-mail:<br>
<input type="email" name="mail" class="form-control" required><br>
Message:<br>
<input type="text" name="comment" size="50" class="form-control" required><br><br>
<button type="submit" value="Send"> Send Message </button>
</form>
...
contact.php
<?php
if($isset($_POST['submit']))
{
$name = $_POST['name'];
$mailFrom = $_POST['mail'];
$message = $_POST['comment'];
$mailTo = "[email protected]";
$headers = "From: ".$mailFrom;
mail($mailTo, $name, $message, $headers);
header("Location: index.html");
}
?>
I added a build.sh file containing:
#!/bin/bash
php contact.php
I also added ./build.sh in build command. I feel my script is wrong. Please suggest me alternatives to solve this problem.
Buddy CI/CD allows you to instantly integrate PHP with Netlify to automate your development and build better apps faster.
Netlify is an awesome service that lets you do continuous integration using git. Each time you push commits, the service gets the changes and rebuild your website. The main issue is that it does not support PHP files, that's why i decided to work on a process to convert PHP website into a static website.
A Netlify site is deployed to a CDN and serves up static content and although you can run PHP at the time of a deploy, you cannot execute PHP during a page request.
To submit a form, you can use Netlify Forms or some other serverless forms solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With