Solved

PHP - sending a variable with image button

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sorting in Excel with Group Headers if the Exist 2 82
Path of Workbook 3 61
creating threads in delphi 1 82
Please explain: Aspect Oriented Programming 2 85
RIA (Rich Internet Application) tools are interactive internet applications which have many of the characteristics of desktop applications. The RIA tools typically deliver output either by the way of a site-specific browser or via browser plug-in. T…
This article will show, step by step, how to integrate R code into a R Sweave document
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 …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

895 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

17 Experts available now in Live!

Get 1:1 Help Now