0

I am designing a PhP application for my project and i want to include a "save,save & new, save & close" function in my forms. all of them are submit buttons. how do i determine which one was clicked?

Bubunyo Nyavor
  • 2,511
  • 24
  • 36

2 Answers2

2

Give them different names and then in PHP check which name is set

HTML

<input type="submit" name="save" value="Save" />
<input type="submit" name="savenew" value="Save & new" />

PHP

if (isset($_POST['save'])) {
  //  save button
} 
elseif(isset($_POST['savenew']))
{
  // save & new
}

etc.

Hanky Panky
  • 46,730
  • 8
  • 72
  • 95
0

Or you can use switch case for this :

switch($_POST['name']){
    case 'Save':
        echo "do code here ";
        break;
    case 'Save & new':
        echo "do code here" ;
        break;

}
sismaster
  • 181
  • 1
  • 13