Solved

Creating a Submit Button using a picture

Posted on 2003-12-10
5
406 Views
Last Modified: 2007-12-19
Does anybody have a simple script to create a Form Submit button using a picture. Thanks,
0
Comment
Question by:Zambian4eva
  • 3
5 Comments
 
LVL 33

Expert Comment

by:snoyes_jw
ID: 9916066
you can use JavaScript and put the picture in a link:

<a href="javascript:void(document.myform.submit())"><img src="source_here"></a>
0
 
LVL 33

Expert Comment

by:snoyes_jw
ID: 9916089
or you can do this:

<INPUT TYPE="image" NAME="submit" src="source_here" alt="Submit">
0
 

Author Comment

by:Zambian4eva
ID: 9916173
I tried the

<INPUT TYPE="image" NAME="submit" src="source_here" alt="Submit">

however my form action =$PHP_SELF

and then this is after

if($submit)
{
call function
}

It will submit however it will not pass the "name" so that the if statement becomes true.

0
 
LVL 33

Expert Comment

by:snoyes_jw
ID: 9916257
You can get around that by adding a hidden element, like <input type="hidden" name="beenSubmitted" value="submitted"> and changing your if statement to if ($beenSubmitted == "submitted")

You might have to use $_REQUEST['beenSubmitted'] depending on how you have global variables set.
0
 
LVL 11

Accepted Solution

by:
shmert earned 125 total points
ID: 9916805
When you use an image as a submit button, PHP passes the X and Y coordinates in the $_POST args.  So, to see if the form was submitted using a given images, you should check:

if (isset($_REQUEST['submit_x'])) {
    // call function
}
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

829 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