tags:

views:

624

answers:

2

I have a script that allows the posting of news. I want to be able to create a 'save as draft' button next to the 'publish' button. How can I allow the 'save as draft' button to pass a value to the back end?

I just need a simple 1 or 0 depending on which button was pressed, I'm using php by the way.

A: 

You can use multiple form elements.

Chad Moran
Nesting a form witin a form? Surely there is a better sollution?
Sam152
+4  A: 
<input type="submit" name="saveasdraft" value="Save as Draft">
<input type="submit" name="save" value="Save">

And then you can detect which button was pressed at the backend by their name. The one that was pressed will be present in the submitted form fields. The others won't be.

cletus
No. As long as its a submit type input in the same form, it'll submit that form. You could use the same name and have the server distinguish between them based on the value but since that value is content that could change, doing it on name is (imho) better.
cletus
Thanks, I tested it out and deleted my comment. It worked great.
Sam152