Can I have more than one type=submit buton ?

I created two type=submit buttons inside php file in the html section.

I am having trouble setting the actions for each button.

Is it even possible to have more than one submit button on a form (in a php file with post action processing done inside the same file ?

I am trying to access each button as:

[php]
if(!empty($_POST[‘button1’])) {do something}
if(!empty($_POST[‘button2’])) {do something else}
[/php]

Does this have a chance to work ?

hello,

yes you can have multiple submit buttons however:

[php]
if(isset($_POST[‘button1’])) {do something}
if(isset($_POST[‘button2’])) {do something else}
[/php]

Thanks,

BTW what is the difference between the two (besides that one may/does not work) ?

Why would I not want to use the not empty version ?

because if it is a button you will better checking if it has been clicked which you can do if isset

empty will apply better for textboxes if is not empty textbox1 then do this.

Thanks for the explanation !
Now I got my program going and understand why.

you are very welcome

Sponsor our Newsletter | Privacy Policy | Terms of Service