php form code and file structure

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ZetCoby
Forum Newbie
Posts: 10
Joined: Wed Sep 28, 2011 1:07 pm

php form code and file structure

Post 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.
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: php form code and file structure

Post 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="" >';)
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
ZetCoby
Forum Newbie
Posts: 10
Joined: Wed Sep 28, 2011 1:07 pm

Re: php form code and file structure

Post 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?
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: php form code and file structure

Post 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
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply