RE: [phplib] Oohforms and submit buttons From: Brian Popp (bpopp <email protected>)
Date: 06/14/01

I often do this too. It's great because you can do all your permission
checking,etc. in one place. You do have to be a little careful with this
though because someone could easily catch on and override your action with
an undesireable alternative. If both actions use roughly the same variables
and you don't do some checking, they could initate a delete when you really
only wanted them doing an update. It might be safer to use a:

switch ( $HTTP_POST_VARS["action"] )

BPopp - bpopp.net

-----Original Message-----
From: Taylor, Stewart [mailto:Stewart.Taylor <email protected>]
Sent: Thursday, June 14, 2001 9:41 AM
To: 'Jesse Swensen'
Cc: phplib <email protected>; 'paul <email protected>'
Subject: RE: [phplib] Oohforms and submit buttons

In my applications I point all my forms to the same action page index.php.

index.php consists of a switch statement, something like

switch ($action) {
case "updateRecord":
   include "act_updaterecord.php";
   break;
case "findRecord":
   include "act_findrecord.php";
   break;
case "displayRecord":
   include "dsp_displayrecord.php";
   break;
default:
   include "dsp_main.php";
   break;
}

Then in my form I have a hidden field named action.

$f->ae("type"=>"hidden",
       "name"=>"action"));

When a submit button is clicked I set action to the relevant value.
e.g.
$f->ae("type"=>"submit",
       "name"=>"Update",
       "value"=>"Update",
       "extrahtml"=>"onclick=\"action.value='updateRecord'\""

If my form has only one text field - as in your case - I initialise the
value of action to the relevant value.

e.g.
$f->ae("type"=>"hidden",
       "name"=>"action",
       "value"=>"findRecord"));

$f->ae("type"=>"text",
       "name"=>"Find",
       "value"=>""));

-Stewart.

-----Original Message-----
From: Jesse Swensen [mailto:swensenj <email protected>]
Sent: 14 June 2001 15:12
To: Paul Smith; phplib <email protected>
Subject: Re: [phplib] Oohforms and submit buttons

You could use JavaScript to set the value for you.

First in you header define what setSubmit does like
<script>
    function setSubmit() {
        document.MyForm.Mysubmit.value = "Submitted";
    }
</script>

In your form declaration you would put something like

<form name="MyForm" onSubmit="setSubmit()">
. . .
    <input type="hidden" name="MySubmit" value="">
</form>

This is a very rough suggestion and you will need to flesh it out. YMMV...

-- 
Jesse Swensen
swensenj <email protected>

> From: Paul Smith <paul <email protected>> > Date: Tue, 12 Jun 2001 15:51:01 -0500 > To: phplib <email protected> > Subject: [phplib] Oohforms and submit buttons > > If you're using oohforms, one way to set things up is to have the form > action be $PHPSELF, then check for the existence of the submit button > to do error checking. However, if there is only one <input type="text"> > element in a form, and you hit return within that element to submit the > form, the submit button doesn't get passed to the action page. You have > to click it with the mouse. > > Is there a better way to do this? How can you check that a form has been > submitted without relying on the submit button? > > -- > Paul Smith <paul <email protected>> > InfoTech Designer > Center for Neighborhood Technology > Chicago, Illinois USA > > --------------------------------------------------------------------- > To unsubscribe, e-mail: phplib-unsubscribe <email protected> > For additional commands, e-mail: phplib-help <email protected> >

--------------------------------------------------------------------- To unsubscribe, e-mail: phplib-unsubscribe <email protected> For additional commands, e-mail: phplib-help <email protected>

--------------------------------------------------------------------- To unsubscribe, e-mail: phplib-unsubscribe <email protected> For additional commands, e-mail: phplib-help <email protected>

--------------------------------------------------------------------- To unsubscribe, e-mail: phplib-unsubscribe <email protected> For additional commands, e-mail: phplib-help <email protected>