Solved

PHP - sending a variable with image button

Posted on 2006-07-23
5
194 Views
Last Modified: 2010-04-17
I have a button but I want to use it to send a variable to the same page if it is pressed

<a  href="#"
onmouseover="document.sub_but1.src='buttons/reset_cream_over.gif'"
onmouseout="document.sub_but1.src='buttons/reset_cream_up.gif'"><img  src="buttons/reset_cream_up.gif"
alt="Move your mouse over me" name="sub_but1" width="82" height="32" border="0" align="absmiddle" id="sub_but1" /></a>

at the top I want to do something like

if (isset($_POST['reset']) {

//do something here

}


any ideas?

0
Comment
Question by:roscoeh23
  • 2
5 Comments
 
LVL 25

Accepted Solution

by:
InteractiveMind earned 250 total points
ID: 17163635
If you wish to submit data to the same page (or any other for that matter), then I believe you need to use a submit button, rather than an anchor.


<?php

   if ( isset( $_POST['reset'] ) )
   {
      // do something
   } else
   {
      <form action="#" type="POST">
         // create some input fields here...
         
         <input type="submit">
      </form>
   }

?>


Does that help?
0
 
LVL 25

Expert Comment

by:InteractiveMind
ID: 17163640
To make that an Image submit button, see here:

http://www.codetoad.com/html/buttons/image_submit_button.asp?x=75&y=19
0
 

Assisted Solution

by:mario_ccs
mario_ccs earned 250 total points
ID: 17215830
Change the <a  href="#"

to

<a  href="your_page.php?variable=value"

then

if (isset($_GET['variable']) {

//do something here

}
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an explanation of a simple data model to help parse a JSON feed
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question