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 9265247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:01:20+00:00 2026-06-18T14:01:20+00:00

I have been creating a website where my users can rate images that have

  • 0

I have been creating a website where my users can rate images that have been uploaded. Currently i use radio buttons and a submit button to get the users rating and save it within the system. I would like to change this so that the code uses image clicks to get the users rating. So far i have the following code however it only works for one image button. Is there any way to change this to get the result depending on what image has been clicked.

Code:

HTML

<form>
<input
        type="image"
        name="flag_submit"
        src="img/Flag.png"
        onmouseover="this.src='img/Flag_Click.png'"
        onmouseout="this.src='img/Flag.png'"
        height="30"
        width="30"
        />
</form>

PHP

if (isset($_POST['flag_submit_x']))
{
    //Do process of rating.
}   

Is there any way that i could create multiple image buttons and in the PHP code detect what image button has been pressed?

  • 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-06-18T14:01:21+00:00Added an answer on June 18, 2026 at 2:01 pm
    1. Change name to an array name="flag_submit[1]". Assign a different value for each image and you got it.

    2. Read it as an array on php side: if (isset($_POST['flag_submit'][1])).

    Or better would be, loop throu if $_POST['flag_submit'] and find all values:

    foreach ( $_POST['flag_submit'] as $value )  {
        echo $value . ' has been clicked.';
    }
    

    <form method="post">
    <input type="image" name="rateButton[1]" src="img/Rate1.png" height="40" width="40" value="1"/> T
    <input type="image" name="rateButton[2]" src="img/Rate1.png" height="40" width="40" value="1"/> T
    <input type="image" name="rateButton[3]" src="img/Rate1.png" height="40" width="40" value="1"/> T
    <input type="image" name="rateButton[4]" src="img/Rate1.png" height="40" width="40" value="1"/> T
    </form>
    <pre>
    <?php
        if ( isset( $_POST['rateButton'] ) ) {
            foreach ( $_POST['rateButton'] as $key => $value ) {
                echo 'Image number '.$key.' was clicked.';
            }
        }
    ?>
    

    In your case, you don’t care, what value it sends, all you need to care about it is the key that was used to submit the form, because there will always be only one key set.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been creating a website to allow users to rate an image uploaded
I have been creating a peer to peer connection for a new game, that
I have been creating an image gallery with jQuery, all is done. The images
So i have been creating this framework thing that basically puts together source code
I have been reading that creating dependencies by using static classes/singletons in code, is
I'm creating a simple mobile website to render specifically on iPhone. I have been
I have been tasked with creating a service that will be consumed by jQuery
I am working on creating a favorites section on my website where users can
I'm founder of a major, so-called 'toplist'. The users can submit their website to
I have been creating a gtk+ application in eclipse. At a point in the

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.