Solved

use form image instead of submit button

Posted on 2006-11-10
2
224 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
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
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…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

776 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