Recent Topics

1 Feb 21, 2008 04:28    

I'm using 1.10.3 on an installation that I over-tweaked like mad to build an online contest of sorts. To do this I need to build a couple of forms, which I've done by cloning the message form. Pretty simple really: stub.php?disp=foo has

$redirect_to = param( 'redirect_to', 'string', '/stub.php?disp=foo_done' );
...
$Form = new Form( $htsrv_url.'do_foo.php' ); 

So htsrv/do_foo.php looks at the data submitted and if good it uploads it to the database and returns the person to the 'foo_done' page with a "thanks" or whatever. Actually it returns to a page that says "thanks - oh and can we have some money cuz we're always broke" but I digress.

What I want to do that is probably painfully obvious is have ?disp=foo contain a form that allows ONE param entered then go right back to disp=foo&param=bar. In other words I don't want to bother with the htsrv bit on the first pass because all I gotta do is query the database to pull info that needs updating. And it's for ONE guy who will be responsible for updating info through the year, so I'm not worried about sanitizing his inputs or anything.

Anyone know how painfully easy this is and feel like making my day?

2 Feb 21, 2008 09:09

$Form = & new Form( regenerate_url( array( 'disp', 'param' ), 'disp=foo' ) );

I think :P

¥

3 Feb 21, 2008 20:03

Cool. Will try it out later today. Always something else is more pressing eh?

Next up is finding the regex that makes sure a value is numbers only. I'm pretty sure I have that one laying about somewhere. Actually I've got it narrowed down to "a hard drive" and I'm pretty sure it's "the first hard drive" so it shouldn't be too hard to find ;)

Yeah the form thing looks good. I then put in a switch that says "if a param that doesn't exist unless someone puts in a value exists then do a different thing". Much nicer than trudging off to htsrv to go right back to the same stupid page so it can go off to htsrv to do it's thing.

4 Feb 21, 2008 23:59

is_numeric() or preg_match( '~^[0-9]+?$~', $foo ); ;)

You could also throw in a if( is_logged_in() && $current_User->ID = bar ) and let evo do all the work ;)

¥

5 Feb 22, 2008 00:45

I didn't know there was a function I could use for "is it a number" but I had the preg_replace thing in an old plugin that I found, so that's done. Checking user inputs sucks ya know? Like, how hard is it to put "4" in instead of "april" when the comment on the form field says "1 or 2 digits for the month (ex 4 for april)"? But you gotta check and recheck everything :(

The quick shortcut back to the same page isn't working as nicely as I had hoped for though. Already that part is tucked inside "is logged in" and "is user id NN" so that the occasional person with powers and abilities gets to see the bits they need, but it doesn't seem to be able to hold the value I give it. Gonna do the easy-but-not-clean solution of trudging off to htsrv long enough to come back because what the heck it does the job.

All so that a bunch of users can tell me it should know everything and they shouldn't have to actually have to input any data :roll:


Form is loading...