Relative Content

Tag Archive for javascriptphphtmlformsemail

I don’t want my email form to redirect to my php file

I created an email form on my website to collect emails using javascript and php. Initially, I attempted to prevent it from redirecting me to www.mywebsite.com/send_email.php by using fetch, but it still redirected me to another page that displayed the message ‘Message Sent! Thank you!’. Eventually, I managed to resolve the issue by embedding the script within the html file. However, I’m curious to know if there is a way to achieve the same outcome of loading on the same home page while keeping the javascript code in a separate js file linked to the html file.