Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-26-2011, 10:29 AM   PM User | #1
IamHe
New Coder

 
Join Date: Mar 2009
Posts: 88
Thanks: 14
Thanked 0 Times in 0 Posts
IamHe is an unknown quantity at this point
image submit not working

Hey guys, im putting a script together and everything was working fine.

heres an extract of what i had:

PHP Code:


if(isset($_POST['submit']) && $_POST['info'] == "go") { 
Code:
   
<form id="form1" name="form1" method="post" action="">
<input type="hidden" name="info" id="info" value="go" />
<input type="hidden" name="id" id="id" value="<? echo $row['id_product']; ?>" />
<input type="submit" width="95" height="29" name="submit" id="submit" value="go">
then i changed the submit from:
Code:
<input type="submit"  width="95" height="29" name="submit" id="submit" value="go">
TO
Code:
<input type="image" SRC="images/go.gif" width="95" height="29" name="submit" id="submit" value="go">
and the script stopped working, so i tried setting the if script to if post image ..rather than if post submit..but that didnt work.
ive never used image submit buttons in the past.
dose anybody have any idea where i have gone wrong.
thanks in advance for any help!
IamHe is offline   Reply With Quote
Old 07-26-2011, 11:05 AM   PM User | #2
low tech
Regular Coder

 
low tech's Avatar
 
Join Date: Dec 2009
Posts: 740
Thanks: 149
Thanked 67 Times in 67 Posts
low tech is on a distinguished road
Hi

see post at 3

http://www.codingforums.com/showthread.php?t=180217

LT
low tech is offline   Reply With Quote
Users who have thanked low tech for this post:
IamHe (07-26-2011)
Old 07-26-2011, 01:12 PM   PM User | #3
BluePanther
Senior Coder

 
Join Date: Jul 2011
Posts: 1,226
Thanks: 3
Thanked 171 Times in 171 Posts
BluePanther is on a distinguished road
You should never check for $_post submit. Some browsers won't pass it if your user presses enter. You should ALWAYS check for a required value in your form only - a value that your user needs to have entered to continue. For you, it looks like post info.

Remove the post submit isset and leave the isset info and it should work.
BluePanther is offline   Reply With Quote
Users who have thanked BluePanther for this post:
IamHe (07-26-2011)
Old 07-26-2011, 01:19 PM   PM User | #4
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,493
Thanks: 44
Thanked 438 Times in 427 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
As BP says, don't use the submit button to test for form submissions. IE has a nasty tendency not to send it when the user hits enter on the keyboard.
__________________
Please wrap your code in [php] tags. It is a sticky topic and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.
tangoforce is offline   Reply With Quote
Old 07-26-2011, 02:09 PM   PM User | #5
IamHe
New Coder

 
Join Date: Mar 2009
Posts: 88
Thanks: 14
Thanked 0 Times in 0 Posts
IamHe is an unknown quantity at this point
Perfect!
Thankyou!
IamHe is offline   Reply With Quote
Old 07-26-2011, 02:14 PM   PM User | #6
IamHe
New Coder

 
Join Date: Mar 2009
Posts: 88
Thanks: 14
Thanked 0 Times in 0 Posts
IamHe is an unknown quantity at this point
Quote:
Originally Posted by low tech View Post
worked great! thanks for your help
IamHe is offline   Reply With Quote
Old 07-26-2011, 02:58 PM   PM User | #7
BluePanther
Senior Coder

 
Join Date: Jul 2011
Posts: 1,226
Thanks: 3
Thanked 171 Times in 171 Posts
BluePanther is on a distinguished road
Quote:
Originally Posted by IamHe View Post
worked great! thanks for your help
Remember, don't use $_POST['submit'] or anything that equates for a user pressing a submit button. It will not work in some browsers.
BluePanther is offline   Reply With Quote
Old 07-26-2011, 04:28 PM   PM User | #8
IamHe
New Coder

 
Join Date: Mar 2009
Posts: 88
Thanks: 14
Thanked 0 Times in 0 Posts
IamHe is an unknown quantity at this point
Quote:
Originally Posted by BluePanther View Post
Remember, don't use $_POST['submit'] or anything that equates for a user pressing a submit button. It will not work in some browsers.
i have always used that way in the past!
lol, i suppose its better to learn later than never!
thanks for your help
IamHe is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:36 AM.


Advertisement
Log in to turn off these ads.