First of all, I’m new to web dev, and I’ve also never used PHP before, so please bear with me and my ignorance.
I’m working on a website, and part of it has an HTML form used to send an email. After some Google searching, I found that a simple PHP script would be the easiest way to do it.
Here’s what I have in my HTML file:
<form method="post" name="myemailform" action="form-to-email.php">
<fieldset>
<legend>Contact us</legend>
<div>
<label for="name">Name: </label>
<input name="name" id="name">
</div>
<div>
<label for="email">Email: </label>
<input name="email" id="email">
</div>
<div>
<label for="message">Message: </label>
<textarea rows="10" cols="40" name="message" id="message"></textarea>
<input type="submit" value="Send Email" />
</div>
</fieldset>
</form>
I’m testing the file locally and for some reason, when I click the submit button, instead of running the script, a new tab opens up displaying the contents of the .php
file in its entirety.
Can anybody please explain to me why this is happening, and what can I do to fix it? Any help would be appreciated!
Edit: Thanks guys! I didn’t know I needed a local server, and I didn’t know that PHP was one of those things I’d need to install. This is really awkward.... Well now I know! Thanks!