Page 1 of 1

two submit buttoms for a form ?

Posted: Fri Mar 30, 2007 3:05 am
by rekha_harnoor
Can I give two submit buttoms for a form?

Posted: Fri Mar 30, 2007 3:14 am
by Kieran Huggins
I know a quicker way to find out than posting on a forum!

Posted: Fri Mar 30, 2007 3:17 am
by s.dot
Yes, you can.

You will need to give each of them the same name, then do what you want with the form depending on the value of the submit button.

Code: Select all

<input type="submit" name="submit" value="Preview" />
<input type="submit" name="submit" value="Post" />

<?php

//proccessing form
switch($_POST['submit'])
{
   case 'Preview':
   //process for preview
   break;

   case 'Post':
   //process for post
   break;
}

?>
At least, that's how I do it.