admin管理员组文章数量:1401611
I’ve been trying to figure out how to submit form data without using PHP code, is there a way? The mailto:
in HTML 5 only has the user fill the form out, then when submit
is clicked, it opens another application (mail app on desktop/laptop, and mail app on smartphones) and puts the data fields inside the message and makes the user click send in their mail, what do I do to at least just make the email sent to my email without the user having to take extra steps? Or being redirected to another app?
I’ve been trying to figure out how to submit form data without using PHP code, is there a way? The mailto:
in HTML 5 only has the user fill the form out, then when submit
is clicked, it opens another application (mail app on desktop/laptop, and mail app on smartphones) and puts the data fields inside the message and makes the user click send in their mail, what do I do to at least just make the email sent to my email without the user having to take extra steps? Or being redirected to another app?
- you don't have to use php for the form submission. You could even use JS for submitting a form. And the mailto haven't anything to do with a form submission. – Sumithran Commented Jun 2, 2019 at 16:01
- You can use EmailJs or SMTPJs to sent the email using javascript. emailjs./docs/sdk/installation , smtpjs. – Jijin P Commented Jun 2, 2019 at 16:02
- this is what you are looking for stackoverflow./a/36656479/7796787 – Amospikins Commented Jun 2, 2019 at 16:08
- 1 It would be better if you explain what you want to acplish by doing this. It sounds you are trying to avoid using a server to process the data. – Juan Commented Jun 2, 2019 at 16:08
- maybe this is what you want stackoverflow./questions/4782068/… – Abed Putra Commented Jun 2, 2019 at 16:22
2 Answers
Reset to default 4If I understand correctly, I think you can do the following. Grab the values of the inputs through javascript and send the email using window.location
with the input values.
HTML
<input type="text" id="subject">
<textarea id="body"></textarea>
<button type="button" id="send">Submit</button>
JS
$('#send').on('click', function(e) {
e.preventDefault();
subject = $('#subject').val();
body = $('#body').val();
window.location = "mailto:[email protected]?subject=" + subject + "&body=" + body;
});
HTML's mailto
process will prompt the user's mail service (outlook, thunderbird, etc.) to open, but none of your form data will be "processed". So, that might not be the best solution for you.
mailto
doesn't respond in exactly the same way for every browser and every email client.- Using this method allows your site visitor to send any information they want to you just by editing the email before they send it to you.
Example: I fill out your form and hit the send (or submit) button. My mail client (Thunderbird) opens with all of the address to, from, subject, and message fields already filled in. I erase the message field and put in "something else". Then I send it to you. You open your email and ... - You are providing your email address to a gazillion webcrawlers who scrub the internet for email addresses to send scams, junk, etc. to on a daily basis.
submit form data without using PHP code
The primary purpose of your script is to process the information before it's sent. The script will parse the data, removing information bits that are ordinarily used in programming. Like, potential Malware code. A form/email script (like this) can be written in any language that will municate directly with the server (provided that the language is on the hosting server)... PHP, CGI/Perl, (maybe javascript?), etc.
What you are looking to do, is match the values in your form to the users answers and then relay that informaiton. In order to do that, you will want to first create your form. When your site visitor fills out the form and hits submit, you want the data to be sent to a script which will check the data, then plete the email fields (to, from, subject, message) and then send it through the server (without exposing your email address to the world).
This is probably a task for an intermediate programmer. That doesn't mean that a "Noob" can't do it, just that it will require a bit of learning to get there. Compare examples online until you find one that makes sense to you.
本文标签: javascriptForm submit without PHPStack Overflow
版权声明:本文标题:javascript - Form submit without PHP - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744224372a2596016.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论