Welcome to WebmasterWorld Guest from 54.162.227.136

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Multiple forms on page and using classes. How to structure?

train of thought needs bump

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

5+ Year Member



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

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

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



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?

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

5+ Year Member



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.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month