I am trying my hand at creating an HTML5 form styled with CSS3. However, in the past, I have only used form building tools that generate the PHP action code. I have found such varied examples online, that I want to ask here if someone can give me an example of simple, clean and valid PHP for a ‘post’ method.
I am going to take advantage of the HTML5 ‘input’ types and attributes, so I would like for the PHP to simply take the data (already validated by the browser through HTML5) and send it to me by email and then display a success message on the website for the sender. Thank you.
Edit: What I am asking for is the code for the PHP file that the form will point to for processing. I know how to do the HTML and CSS, but would appreciate an example of the PHP code to complete the actions I mention above.
It seems you are confusing html5 with css3 with php. They are all separate technologies that are used together. A form is just a form. You submit it and your php processes it. You need to read about post and get processing in php. For the html side you just submit a form and specify which of the two methods (get or post) you want to use
Handling emailing stuff to yourself is whole other can of worms. Get this down first and then ask that part in a new SO question.
Update – based on update to question by OP
The two things you are looking for are pretty simple. First create a php file that the form submits to. In my example above I chose
blah.php. There you can query the global variable$_POST[]. This variable will contain a hash for each inputnameand inputvalue. In the example above these arefooandhello world.You can then use the php mail method to send an email to yourself.
And finally whatever you echo out will be returned to the user