Friday, November 25, 2005

Use multiple submit buttons on one form using PHP

<form>

<input type="submit" name="submit" value="NEW" />

<input type="submit" name="submit" value="SAVE" />

<input type="submit" name="submit" value="EDIT" />

</form>

<?php


switch ($_GET['submit']) {


case 'NEW':

print 'This is what happens when new button is clicked.';

break;


case 'SAVE':

print 'This is what happens when save button is clicked.';

break;


case 'EDIT':

print 'This is what happens when edit button is clicked.';

break;


default:

print 'You can put the html form here.';

break;


} // End: switch ($_GET['submit'])


?>


No comments: