Solved

use form image instead of submit button

Posted on 2006-11-10
2
226 Views
Last Modified: 2006-11-18
Hello, I use image instead of submit form button and I tried to update user information, But it does not work. What I need to do to resolve this problem??

<?PHP
require_once('../log/dbini.php');
$conn=mysql_connect($DBSERVER,$DBUSER,$DBPWD);
$select_db=mysql_select_db($DBNAME,$conn);

$MYNAME=$_REQUEST['myname'];
$sql="UPDATE tbluser SET MYNAME='".$MYNAME."' WHERE USER1 = '".$_SESSION['USER1']."'";
$rst=mysql_query($sql);

?>

<form action="<?=$_REQUEST['PHP_SELF']?>" method="post">
<input type="text" name="myname">
<input type="image" name="update" value="update"  src="abc.jpg">
</form>
0
Comment
Question by:portal123
[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
2 Comments
 
LVL 9

Accepted Solution

by:
tolgaong earned 400 total points
ID: 17918605
<form action="<?=$_REQUEST['PHP_SELF']?>" method="post">
<input type="text" name="myname">
<input type="submit" name="submit">
<img src="abc.jpg" onclick="document.forms[0].submit.click"> // you can check the form onsubmit event
<img src="abc.jpg" onclick="document.forms[0].submit()">     // you cannot check before the submit...
</form>
0
 
LVL 1

Assisted Solution

by:spdaniel91
spdaniel91 earned 100 total points
ID: 17921019
$MYNAME=$_REQUEST['myname'];
$_REQUEST['PHP_SELF']

NEVER ever use $_REQUEST. Because, imagine the form says the name is Nick, but the url is:

http://justexample.com/add.php?name=Dan

What one does it use? Sometimes one, sometimes another. Always use $_GET or $_POST.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

726 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