Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 5th, 2005, 01:01 PM
Registered User
 
Join Date: May 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default OOP:FormCreation\Validation -Paradigm shift needed

Hi,

I have been programming with php for the last two years. However, everything I have done has always been procedural programming. So, I would like to step over to the dark side and start shifting my thought process to OOP. I have no history with OOP and am having a hard time not slipping back into the procedural programming even when I structure my class(es).

I am hoping someone will walk me through the thought process (not code).
I need real life projects to play with and thought that this is one people could understand.

SCENARIO: I build a lots of forms. Huge amount of forms. I hate coding forms. I also do not trust any data submitted from a form. So I validate it, tweak it, submit it. I hate coding validation.

PROPOSED SOLUTION: Create a FormCreation class to create and display the form (in 4 states ie, add data, edit existing data, delete data, show error message if data sent is no good). Create a FormValidation class to validate the new data. If there is bad data it reloads the form and shows the error message.

SUMMARY: I know there are form validators out there that can be used. I am not interested in modifying someones script I am more interested in achieving the thought process and accomplishing the said above task.

Anyone interested in helping retrain my mind?

I think I can... Ithink I can... I think Ican...
Choo Choo
 
Old May 7th, 2005, 10:58 AM
Authorized User
 
Join Date: Jan 2005
Posts: 82
Thanks: 0
Thanked 0 Times in 0 Posts
Default

First let me say that I am in the same boat as you are; in fact, I have never coded anything in an OOP level. Though I have read like a million articles, I still have a vague idea of how to write a class.
I am going to write what I would do to create such a class and since I know its not gonna be good, I am hoping that someone with better knowledge of OOP can help us understand this.

--------------------------------

A class has its own properties and its own methods. Let's think of a real world example like a soccer ball. A soccer ball has a shape (spherical), a diameter, a raedius (diameter/2), weight, internal pressure and so on and so on. It also has methods (actions): it bounces.
In the same manner the form has properties like name, id and methods like post, get, onSubmit, and so on.

If we were to write a simple class with these in mind it should look something like this draft:

Class someform{

var name;
var id;

    function whensubmitted {
       do this;
     }

}

------------

so far thats been my idea of how to write a class, but where am i going wrong?

----------------
Never bother to learn something not knowing which does not do you any harm, and never neglect to learn something whose negligence will increase your ignorance - Imam Jafar Sadeq
 
Old May 9th, 2005, 10:03 PM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 117
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Hi,
I always want to be on OOP Level, but the problem is no books no website,... can teach how to be OOP?
I search lots of websites and still cannot find any solution.
In my side I really want to create spider(s) (Robots) and all I found is nothing. (not even on Prel).







Similar Threads
Thread Thread Starter Forum Replies Last Post
Regex help needed for form validation Lucy Javascript How-To 2 February 1st, 2006 10:47 AM
OOP design raj_sekhar C++ Programming 1 August 23rd, 2005 11:44 AM
Shift + Enter OR Shift+Double-Click phungleon Access 2 May 20th, 2004 10:14 AM
OOP with JavaScript Moharo Javascript 3 September 29th, 2003 10:14 AM
Values of one form needed for validation on anothe nazneen JSP Basics 0 June 19th, 2003 03:18 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.