- b2evolution CMS Support Forums
- b2evolution Support
- General Support
- okay i'm stupid on a form thing
1 edb Jun 15, 2007 19:36
My b2evolution Version: Not Entered
How does "param" work? Here's the deal for me: I am using a hacked up version of msgform.php to make a registration form, and a hacked up version of htsrv/_message_send.php to listen to the form. Both work because I can see the fields selected in email and stored in the database (thanks yabba!). What I can't do is make a redirect page that reacts to the stuff the user clicked on.
I have been trying to redirect back to the initial form with a "&done=done" tacked on, and that works, but it's not figuring out what the person clicked on after that. Therefore I can not customize the page they see after they submit the form based on actual data.
For example I ask if they want to spend $10 on a dinner for another person, and if so what their meal choice is. I see in my email and database that the field "other_meal" has a value of either 'none' (default) or the name of the dish they chose. Okay cool, but this doesn't work:
if( $mtd != '' ) { // we have a value so they already filled in the form
$initial_text = 'Your options (registration';
if( $drivers_meal != 'none' ) {
$total_cost = $total_cost + 10;
$initial_text .= ', dinner for your driver';
}
No matter what I click on it tells me they bought a dinner for the driver!
I can think of a couple of ways to beat this problem to death, but I'm pretty sure I'm missing something about how "param" works it's magic. For example if $mtd=done I could query the database for the information the file in htsrv just added, then use that info to do the calculations and stuff. It seems sloppy from a server-load perspective, but it'll work. I could also make $mtd be a string where each character means a value of the form that matters to me. So like the first character is payment method (p or c for paypal or check) then pilots meal then drivers meal and so on and so on. That seems like sloppy code even though it doesn't hit the database with another query.
Ultimately I think it's a lot easier than I'm making it, so I figured rather than beat my head against this problem for another day or two or three I'd just ask here for some help.
After htsrv/message_send.php does it forget all the form field values? If not how can I access them on the same page that they initially filled in? Should I be redirecting to a different page? Would that allow me to use the values from the form fields? I am thinking that having, for example, "$drivers_meal = param( 'drivers_meal', 'string', '' );" is setting that value back to '' even though they already clicked on it.
This hurts my brain.
A lot.
hmmm... I'm starting to think fondly of the first disp= being a page to fill in the forms and the redirect being a disp= page that knows all the fields are filled in. I hate to throw out what I've got, but since it's not working the way I want I guess I got nothing good to lose...
Anyway bottom line is I'm probably missing something simple, so asking is better than guessing.
Short term I went with encoding information in a redirect. It is probably not the most efficient way to do it, but it works so it's cool. Plus I have to have something online yesterday...
Damn I wish I actually understood how this stuff works :(