Page 1 of 1

php form code and file structure

Posted: Sun Jul 22, 2012 11:40 pm
by ZetCoby
Hello, i am a bit confused, where is the best place to write the code of a form? in the same file where the forum it self is located or in a other php file?
what structure to use? how do u guys organized you site files? can someone please tell me what is the best way to organize your files in folders? but a other way besides MVC, the problem is that i don`t use frameworks yet, i am still learning php.

Re: php form code and file structure

Posted: Mon Jul 23, 2012 4:28 am
by social_experiment
ZetCoby wrote:i am still learning php
Are you familiar with classes? Personally i keep files that do different things separate. How do you plan to create the form - procedural code or by directly echoing html fragments via php (i.e echo '<form action="" method="" >';)

Re: php form code and file structure

Posted: Tue Jul 24, 2012 2:31 am
by ZetCoby
yes i am familiar with classes.
well forms i create them directly in html and after i send the info in a other php file to process it but i don`t know if this is the best method to do.
Is it better to create forms in php in echo?

Re: php form code and file structure

Posted: Tue Jul 24, 2012 3:13 am
by social_experiment
If the forms are static then the current method you are using is good, stick with it for now :)

There are developers who advocate using php to generate html while others advise against it; imo it is good to evaluate what is required of the situation and proceed according to that.

Below are two urls that shows the different approaches.

http://davidwalsh.name/create-html-elem ... ment-class
Shows how you can use php to create html

http://www.php-beginners.com/embedding-php-in-html.html
Shows how you can embed php in an html document

Hth