Solved

PHP - sending a variable with image button

Posted on 2006-07-23
5
187 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
how to open Waze.com/livemap from address saved in DB? 26 154
dividesSelf challange 15 82
noX challenge 17 77
stringclean challenge 26 58
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
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…
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 …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now