I have been working on a small website and wanted to add a contact us page. The rest of the website is just 3 html files and a css style sheet. I have created the form in a fourth html file, contact-us.html, but I am not sure how best the PHP to send the email should work.
I have tried having a separate PHP file, contact-send.php, which is linked to using action="contact-send.php", then this PHP file sends the email, but what the user sees is just a blank page, the contact-send.php page, when they click submit. I want the user to be ideally taken to a page that says success if the form is sent or allows them to make changes if the information entered was not right.
I have seen people have a PHP file for the contact-us page which includes the html for the form, but I didn’t know if it was good to have the code that sends the form visible on the same page.
If I have the PHP to send the email in a separate file, how can this then update the webpage if the email is successfully sent, either by redirecting to a new page or by updating the content of the current one.
This website is just being hosted on Linux servers.
What different files should be used ? Should I have the main contact page be a php file which also sends the message, or should it be a separate file which is then able to redirect the page?