homepage Welcome to WebmasterWorld Guest from 50.17.79.35
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Multiple forms on page and using classes. How to structure?
train of thought needs bump
immols




msg:3850647
 2:42 pm on Feb 16, 2009 (gmt 0)

I started using classes in php. Fun!

I now have a form, which is generated by a class. Submitting this form (with ajax or method=post and a submitbutton) raises a problem for me.

Usually, i have the current page in the 'action =' and if a certain condiion is met, a function on a 'functions.php' is executed.

Now that i use classes, i would like to have all intelligence out of the pages and into the class. (Please don' tell me to start using a 'real' language :)) I would love to have this:
<form mehod="post" acion="$object->function()" >

But that's not possible. So how to proceed. I do have a lot of separate forms on that page, and on all other pages (don't ask me, it's a trial-thingy). I woul not like to post on every page a number of conditional statements asking: if this form has nbeen submitted, then please do this, but if it was he other form...

I know i don't give much o go on, but that's bcs it's a bit vague in my head atm.
Any suggestion is welcome.

Regards

 

penders




msg:3850738
 4:54 pm on Feb 16, 2009 (gmt 0)

The HTML action attribute takes the URL of the page you want to send the form data to, which can be the current page or any PHP file that is set up to process your form data. This is the same, whether you are coding using classes or functions.

You probably want to set the action attribute to the same PHP script that is instantiating your class that generates your form?

immols




msg:3850743
 5:02 pm on Feb 16, 2009 (gmt 0)

Yes, and that is what i did.

I would be so much happier with it, though if there were anoher way of dealing with it :-)

It's like the code is 'broken' already, by not having all intelligence in the objects themelves. So i was wondering if there was another way of thinking to which i an not used to.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved