From: "Richard Lewis" <[EMAIL PROTECTED]>

> >In all fairness to IE, it WILL send the value of each button - but PHP
> >cannot distinguish between them all because you have given them all
> >the same name! :)
> >
> >RL> Does <input type='submit'...> allow this sort of functionality?
> >
> >If it has a unique name, sure:
> >
> ><input type="submit" name="something-unique">
>
> So what if I want to know which button was pressed to submit the form?
>
> At the moment I have:
>
> switch ($_POST['submit'])
> {
> case "edit": ...
> case "new": ...
> }

You can have multiple submit buttons, each one just needs to have a unique
name or value.

<input type="submit" name="submit" value="New">
<input type="submit" name="submit" value="Edit">

Now, when either of those buttons are pressed, you'll end up with one
$_POST['submit'] variable that'll either have a value of "New" or "Edit". So
you can do exactly what you want above, just be sure to match up the case
(new vs. New, etc).

You can also do it with unique names:

<input type="submit" name="edit_submit" value="Edit this Record">
<input type="submit" name="new_submit" value="Add New Record">

Now, depending upon which button was pressed, you'll either have
$_POST['edit_submit'] or $_POST['new_submit'], but not both.

if(isset($_POST['edit_submit']))
{ //do edit stuff }
elseif(isset($_POST['new_submit']))
{ //do new stuff }
etc...

---John Holmes...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to