How to collect 'contact-us' form (user submitted ) data? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

How to collect 'contact-us' form (user submitted ) data?

I have a 'Contact us' page on a static website. What is a good way to collect the info submitted by a user. And how to collect it? (PS: It is convenient to send this form info to an email.) (PPS: This is a basic static website, there is no database, I have negligible knowledge of database.)

8th Nov 2018, 8:25 PM
Zubair Khan
Zubair Khan - avatar
3 Respostas
+ 2
Backend needed which isn't in sololearn Heroku is good option but I haven't used ever. I have seen many codes running on it. Also, firebase .
8th Nov 2018, 8:36 PM
Roneel
Roneel - avatar
+ 1
There is no way to do it with a static website -- Hence the term "static". If you have the ability to create a serverside script (in PHP, since that was one of your keywords") that is fairly simple to do. Author your contact form and set the method to be POST and the target to be your contact-us.php With PHP your form elements will exist in a superglobal array $_POST. You can check the input, and if it's valid send the relevant contents of the form to yourself using the php mail() function. Here's a simplified sample: https://code.sololearn.com/wbQzccpOGNHN/#php Use all the HTML5 form validation you can to insure your form is complete prior to submission, but check in the PHP script for all the inputs you require.
8th Nov 2018, 9:34 PM
David Rolston
David Rolston - avatar
+ 1
Hi David Rolston thanks, it looks complicated, let me go through your code
8th Nov 2018, 9:40 PM
Zubair Khan
Zubair Khan - avatar