Solved

Creating a Submit Button using a picture

Posted on 2003-12-10
5
409 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

617 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