Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

PHP - sending a variable with image button

Posted on 2006-07-23
5
Medium Priority
?
200 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
3 Comments
 
LVL 25

Accepted Solution

by:
InteractiveMind earned 1000 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 1000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This is about my first experience with programming Arduino.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Progress
Loops Section Overview

876 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