Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 195331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:40:19+00:00 2026-05-11T16:40:19+00:00

The problem I have is that I have multiple submit inputs in a single

  • 0

The problem I have is that I have multiple submit inputs in a single form. Each of these submit inputs has a different value and I would prefer to keep them as submit.

Whenever the user presses Enter, it is as though the topmost submit input is being pressed, and so it is causing problems for the code checking which input was clicked.

Is there a way for PHP to determine whether or not the input was clicked, or was just the input that was selected when the user pressed the Enter key?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T16:40:19+00:00Added an answer on May 11, 2026 at 4:40 pm

    You can identify which button was used provided you structure your HTML correctly

    <input type="submit" name="action" value="Edit">
    <input type="submit" name="action" value="Preview">
    <input type="submit" name="action" value="Post">
    

    The $_POST array (or $_GET/$_REQUEST) will contain the key “action” with the value of the enacted button (whether clicked or not).

    Now, “clicking” is explicitly a client-side behavior – if you want to differentiate between a click and a keypress, you’ll need to add some scripting to your form to aid in that determination.

    Edit

    Alternatively, you can be “sneaky” and use a hidden submit that should correctly identify a key-pressed for submission, but this probably has some significant impact on accessibility.

    <?php
    
    if ( 'POST' == $_SERVER['REQUEST_METHOD'] )
    {
        echo '<pre>';
        print_r( $_POST );
        echo '</pre>';
    }
    
    ?>
    <form method="post">
    
        <input type="text" name="test" value="Hello World">
    
        <input type="submit" name="action" value="None" style="display: none">
        <input type="submit" name="action" value="Edit">
        <input type="submit" name="action" value="Preview">
        <input type="submit" name="action" value="Post">
    
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 119k
  • Answers 119k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer this is final. You definitely cannot assign it. I'd guess… May 11, 2026 at 11:54 pm
  • Editorial Team
    Editorial Team added an answer The problem is that the mouseover and mouseout events bubble… May 11, 2026 at 11:54 pm
  • Editorial Team
    Editorial Team added an answer The "official" approach is to simply delete any out of… May 11, 2026 at 11:54 pm

Related Questions

I'm just starting out with the whole ajax thing and I need some help.
I have an ASP.NET page that requires the ability to have users enter multiple
I'm new to javascript, my problem is effectively: I have a php page that
I have a View with an exposed form . I am trying to a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.