I agree with using php rather then HTML emailing. Once you get it set up, it's a lot easier for everyone. I personally hate those messages as well
BUT, you have to keep in mind that your webhost needs to meet the requirements for emailing as well, and some don't. The webhost needs to:
- Be PHP enabled
- Have an SMTP server (which you have access to)
And the page will need a .php extension rather then .htm (in case you didn't know).
Also, a small correction in the PHP code-- I know it is just an example, but that code will send a blank email before the real email, which will get old really fast. (Or maybe it outputs a blank subject/message error?)
Code:
<?php
if(isset($_POST['submit'])){ // <-- Will not email unless form was submitted
mail('email',$_POST['sub'],$_POST['message']);
}
?>
<form action="" method="post">
<input type="text" name="sub" /><br />
<input type="text" name="message" />
<input type="submit" name="submit" />
</form>
The button to redirect uses can be done using PHP:
Code:
<?php
if(isset($_POST['submit'])){
header("Location: form.php");
}
?>
<form action="" method="post">
<input type="submit" name="submit" value="Send Email" />
</form>
Or javascript:
Code:
<script type="text/javascript">
function emailform(){
window.location = "./form.php";
}
</script>
<input type="button" value="Send Email" onclick="emailform()" />
Bookmarks