Is there any difference between a html form and a php form?
Get the solution ↓↓↓So I’ve started this project for uni a couple of weeks ago, and we started learning html, css and javascript. I did some pages, forms, js validation etc., but now I’m kinda stuck on php. When I try to look to videos about how to do validation with php, etc., some people put their forms in a php file, while mine is in html file. Is there any difference. I took a look at my friends project and it looks like he has them both, in a html file and in a php file. Is there any difference? Should I have them both in a html file and in a php file?
Sorry the instructions weren’t clear, but it seems like I was wrong from the getgo on what a php file actually is. Thanks.
Answer
Solution:
The difference in where you put your<form>
is that a .php file may contain PHP code, while a .html contains HTML only :)
In practice that means that you can put PHP code within your HTML markup (it won't be seen by the client). PHP code within .html file wouldn't be executed and would be a piece of regular text.
I usually set all my View files as .php for the sake of using PHP for dynamic generation and accessing the server-side data within it by and so on.
As for whether the<form>
itself is different? No. It's the same HTML code.
PS! I forgot to mention this, it's kinda important. PHP validation on POST is much more secure, not only that, but Javascript and HTML validation only are not secure. because pure HTML one won't be back-side. Probably javascript or stuff likerequired
,maxlength=""
in an input. Those are NOT secure and should always be double checked on the back-side if the validation matters (like passwords, for legal reasons, et cetera.)
To try this out for yourself, you can make a form, open developer tools with F12 and cut out the maxlength, required etc., you'll see that you can submit the form even without valid data. As you can't actually see the back-side PHP code (it's stripped from the file you receive, you get pretty much a simple .html after the PHP is executed), you can't do this with that type of validation.
Answer
Solution:
there are only one html form that can use in php file. means you can use html code in php file. there are no different php form this is only html form using html form you can submit data to database using html post and get method.
refer link for more information
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: using $this when not in object context laravel
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.