Reputation: 87
I'm in the process of making a static site. I've got a testimonial page in which there is a form to add testimonials that I want to send responses to a selected email. There is the html MAILTO function. But I don't much care for that feature as I feel many people wishing to submit a testimonial won't have outlook etc set-up to do so or won't be comfortable with it. I've been unable to find an alternative to this for a static site.
Is there an alternative? If so, what is it?
*Edit: I don't necessarily need it conveyed to an e-mail, any way to access the information submitted would be fine.
Upvotes: 3
Views: 969
Reputation: 1005
You can use a tool such as JotForm or any other form service through and iframe, or sometimes you can embed it into the page and they handle the rest. If you want to do it the PHP way you can create a form and name the inputs with their respective names, then you can send the results to an email. You can use the following code to send an email, but you'll need to put your variables in there.
<?php
$to = '[email protected]';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: [email protected]' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
If you're not looking to do much work with PHP, since it might get a bit complicated if you are new to PHP you might as well go with JotForm. You can also check out Formstack and Woofuu if you're up for paying
Upvotes: 1
Reputation: 11721
In a nutshell: your HTML:
<form action='mail.php' action='post'>
<input type='text' id='inputName'>
<textarea id='feedback'></textarea>
<input type="submit">
</form>
The shortest possible PHP script to mail the info from the form:
<? mail($to,$subject,print_r($_POST,true)); ?>
This will result in an email like this:
Array
(
[inputName] => Name Entered
[feedback] => Feedback entered
)
for $to you can use your email address, and the subject is pretty straight forward as well
Upvotes: 0