faqts : Computers : Programming : Languages : PHP : Common Problems : Forms and User Input

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

98 of 134 people (73%) answered Yes
Recently 6 of 10 people (60%) answered Yes

Entry

How can I have two submit buttons in the same HTML form?

Aug 15th, 1999 07:56
Nathan Wallace,


What you need to do is to set different names for each submit image
button like this:

    <input type="submit" name="type_1" value="Button 1">
    <input type="submit" name="type_2" value="Button 2">

Then to check if the form was submitted try:

    if(IsSet($type_1))
    {
        echo "form was submitted by button 1.";
    }
    else
    {
        if(IsSet($type_2))
        {
            echo "form was submitted by button 2.";
        }
        else
        {
            echo "form was not submitted by any of the known buttons";
        }
    }