"Submit button is an image" problems

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

"Submit button is an image" problems

Post by evilmonkey »

Hello. I have a submit button, which is an image. The basics of this is as simple as: it works in firefox, doesn't work in IE. The weird thing is, in IE, it still acts as a link and reloads the page perfectly, but doesn't perform the SQL query I need it to perform. Firefox does this perfectly. Below is the code:

Code: Select all

<form action="profile.php?{$id}" method="post" name="FormName">
										<table width="364" border="0" cellspacing="0" cellpadding="0" cool gridx="2" gridy="2" height="154" usegridx usegridy>
											<tr height="4">
												<td width="4" height="153" rowspan="3"></td>
												<td width="359" height="4" colspan="2"></td>
												<td width="1" height="4"><spacer type="block" width="1" height="4"></td>
											</tr>
											<tr height="78">
												<td width="359" height="78" colspan="2" valign="top" align="left" xpos="4"><textarea style="BORDER-RIGHT: #E8E8E8 1px solid; BORDER-TOP: #E8E8E8 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #E8E8E8 1px solid; BORDER-BOTTOM: #E8E8E8 1px solid; FONT-FAMILY: Verdana; BACKGROUND-COLOR: #E8E8E8" name="shout" rows="4" cols="55"></textarea></td>
												<td width="1" height="78"><spacer type="block" width="1" height="78"></td>
											</tr>
											<tr height="71">
												<td width="62" height="71"></td>
												<td width="297" height="71" valign="top" align="left" xpos="66"><input type=image name="submit" value="newshout" src="images/button_overlay.gif" alt="" width="100" height="14" border="0"></td>
												<td width="1" height="71"><spacer type="block" width="1" height="71"></td>
											</tr>
											<tr height="1" cntrlrow>
												<td width="4" height="1"><spacer type="block" width="4" height="1"></td>
												<td width="62" height="1"><spacer type="block" width="62" height="1"></td>
												<td width="297" height="1"><spacer type="block" width="297" height="1"></td>
												<td width="1" height="1"></td>
											</tr>
										</table>
									</form>
That was the template, this is the PHP that takes care of it:

Code: Select all

if ($_POST['submit']=="newshout"){
	//if a user is logged, he "shouts" as himself
	if (isset($_SESSION['id'])){
		$user_profile->sb_add_shout($id, $current_user->username, $_POST['shout']);
	}
	//if a user is not logged in, he "shouts" as annonymous
	else {
		$user_profile->sb_add_shout($id, "Annonymous", $_POST['shout']);
	}
}
Any help on the matter is appreciated!

Thanks.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

look at the data in $_POST, you'll find submit_x or similar .. last I checked, when you get these versions, you will not get the value associated with the submit button. This can be overcome in a few ways:
  • don't use an image submit button, or at least don't rely on the value of the submit button.
  • use a client-side script to set a hidden form element with the value of the submit button being clicked
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

Okay...i can use the isset($_POST['submit]) check or will that fail too?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

typically, you shouldn't rely on the submit button existing. The form can be submitted (validly) without it.
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

Hidden feild then?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

yep..

Thread moving to Client-side.
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

Got it using a hidden feild, thanks.
pilau
Forum Regular
Posts: 594
Joined: Sat Jul 09, 2005 10:22 am
Location: Israel

Post by pilau »

Hidden fields rule. Honestly. I used them twice when I made the admin control panel for my current website (http://cryhavoc.owns.it - check it out it's really cool)
bladecatcher
Forum Commoner
Posts: 67
Joined: Sat Mar 12, 2005 12:50 am

Post by bladecatcher »

Pilau

I take it your white guys? Shouldn't have used a white background for photo's ;-)

No images! (on "Band" page.

Using FF 1.06 in XP.

cheers
Post Reply