PHP generated HTML has submit button which picks up the wrong url.
PHP generated HTML has submit button which picks up the wrong url.
am 05.02.2010 21:10:39 von Mary Anderson
Hi,
I am writing code in PHP which generates HTML script. My app is
fairly complex. Twice in the development of the application I have run
into a problem with submit buttons which pick up the wrong url. Instead
of call the url for that submit button, it appears to call the url for
the first submit button on the page. The problem may be intermittent,
which seems to suggest that something funny is happening with the
cache. Clearing the cache did not help in the last go around.
I am including the generated html code. Hitting the button 'Retrieve
all ...' should call up the url get_query_forms.php. Instead it calls
up the url query_form_display_data.php, which is the url for the first
submit button on the page.
Any clues to clear up this mystery would be greatly appreciated!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: PHP generated HTML has submit button which picks up thewrong url.
am 05.02.2010 21:33:02 von Joseph Thayne
This is actually a javascript issue rather than a PHP issue. What is
happening is that the action of the form is what is being submitted.
The action never changes. What you need to do is have the javascript
change the action as well as submit the form (which means you will need
to move it to a function). It would also help to empty out the form
action as well.
Example JS function:
function retrieveAllPerm()
{
document.display_data.action='http://unproto.demog.berkeley. edu/memdemo/edit_query_form.php?perm_batch_file=perm&pg_quer y_form_id=518&query_form_schema=permanent_queries';
document.display_data.submit();
}
Example submit button:
onClick="javascript:retrieveAllPerm();" >Revise query
Joseph
Mary Anderson wrote:
> Hi,
> I am writing code in PHP which generates HTML script. My app is
> fairly complex. Twice in the development of the application I have
> run into a problem with submit buttons which pick up the wrong url.
> Instead of call the url for that submit button, it appears to call the
> url for the first submit button on the page. The problem may be
> intermittent, which seems to suggest that something funny is happening
> with the cache. Clearing the cache did not help in the last go around.
> I am including the generated html code. Hitting the button 'Retrieve
> all ...' should call up the url get_query_forms.php. Instead it calls
> up the url query_form_display_data.php, which is the url for the first
> submit button on the page.
>
> Any clues to clear up this mystery would be greatly appreciated!
>
> Mary Anderson
>
> ------------------------------------------------------------ ------------
>
>
>
>
>
>
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
>
>
On Fri, 2010-02-05 at 14:33 -0600, Joseph Thayne wrote:
> This is actually a javascript issue rather than a PHP issue. What is
> happening is that the action of the form is what is being submitted.
> The action never changes. What you need to do is have the javascript
> change the action as well as submit the form (which means you will need
> to move it to a function). It would also help to empty out the form
> action as well.
>
> Example JS function:
> function retrieveAllPerm()
> {
> document.display_data.action='http://unproto.demog.berkeley. edu/memdemo/edit_query_form.php?perm_batch_file=perm&pg_quer y_form_id=518&query_form_schema=permanent_queries';
> document.display_data.submit();
> }
>
> Example submit button:
>
> onClick="javascript:retrieveAllPerm();" >Revise query
>
> Joseph
>
> Mary Anderson wrote:
> > Hi,
> > I am writing code in PHP which generates HTML script. My app is
> > fairly complex. Twice in the development of the application I have
> > run into a problem with submit buttons which pick up the wrong url.
> > Instead of call the url for that submit button, it appears to call the
> > url for the first submit button on the page. The problem may be
> > intermittent, which seems to suggest that something funny is happening
> > with the cache. Clearing the cache did not help in the last go around.
> > I am including the generated html code. Hitting the button 'Retrieve
> > all ...' should call up the url get_query_forms.php. Instead it calls
> > up the url query_form_display_data.php, which is the url for the first
> > submit button on the page.
> >
> > Any clues to clear up this mystery would be greatly appreciated!
> >
> > Mary Anderson
> >
> > ------------------------------------------------------------ ------------
> >
> >
> >
> >
> >
> >
> > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> >
> >
> >
Bit of advice though, don't use Javascript to submit a form. Firstly,
Javascript isn't available on all browsers, and on those it is available
on, not everyone has it turned on. The W3C has the stats for Javascript
being unavailable in a browser at about 5%. Imagine that your site is
only aimed at the population of the UK, 5% of 61 million is still over 3
million people. Obviously that doesn't take into consideration the ages
of people who'd be using your site, but it's worth stopping and thinking
about. Also, anyone using a mobile is unlikely to have Javascript
enabled too, and a lot of people use mobiles these days for browsing and
such whilst on the move.
Secondly, you're using the onclick handler to submit a form. This is
very bad, as you totally alienate anyone who visits your site that has a
disability that prevents them using a mouse. So, anyone with hand
problems like severe arthritis or missing hands, or anyone who is blind
is shut out from your site.
What you maybe ought to consider is using several submit buttons, and
give each a name and a value. That way, your PHP script can check for a
specifically named variable sent from the form. That way, you keep many
people happy, and your site still works perfectly.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--=-Y+9NprVJP1dFmJb6pfn5--
Re: PHP generated HTML has submit button which picks up thewrong url.
"What you maybe ought to consider is using several submit buttons, and
give each a name and a value. That way, your PHP script can check for a
specifically named variable sent from the form. That way, you keep many
people happy, and your site still works perfectly."
The problem with doing it that way is that IE is not happy with multiple
submit buttons in a single form. To get around that, you can use image
input types or buttons. Also, a return key does not send values the
same way as a mouse click. I can't remember which browser does what,
but the three possible submitted values are (providing the name of the
button is submit):
submit
submit_x and submit_y
submit_x, submit_y, and submit
Just something to be aware of if you are looking for the value of the
submit button -- not 100% reliable. It would be better to use a hidden
form value or just check to see if submit or submit_x is set.
Joseph
Ashley Sheridan wrote:
> On Fri, 2010-02-05 at 14:33 -0600, Joseph Thayne wrote:
>> This is actually a javascript issue rather than a PHP issue. What is
>> happening is that the action of the form is what is being submitted.
>> The action never changes. What you need to do is have the javascript
>> change the action as well as submit the form (which means you will need
>> to move it to a function). It would also help to empty out the form
>> action as well.
>>
>> Example JS function:
>> function retrieveAllPerm()
>> {
>> document.display_data.action='http://unproto.demog.berkeley. edu/memdemo/edit_query_form.php?perm_batch_file=perm&pg_quer y_form_id=518&query_form_schema=permanent_queries' ;
>> document.display_data.submit();
>> }
>>
>> Example submit button:
>>
>> onClick="javascript:retrieveAllPerm();" >Revise query
>>
>> Joseph
>>
>> Mary Anderson wrote:
>> > Hi,
>> > I am writing code in PHP which generates HTML script. My app is
>> > fairly complex. Twice in the development of the application I have
>> > run into a problem with submit buttons which pick up the wrong url.
>> > Instead of call the url for that submit button, it appears to call the
>> > url for the first submit button on the page. The problem may be
>> > intermittent, which seems to suggest that something funny is happening
>> > with the cache. Clearing the cache did not help in the last go around.
>> > I am including the generated html code. Hitting the button 'Retrieve
>> > all ...' should call up the url get_query_forms.php. Instead it calls
>> > up the url query_form_display_data.php, which is the url for the first
>> > submit button on the page.
>> >
>> > Any clues to clear up this mystery would be greatly appreciated!
>> >
>> > Mary Anderson
>> >
>> > ------------------------------------------------------------ ------------
>> >
>> >
>> >
>> >
>> >
>> >
>> > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>> >
>> >
>> >
>> >
>> > Display Data
>> >
>> >
>> > action=./query_form_display_data.php?perm_batch_file=perm&pg _query_form_id=518&data_table_id=255&data_batch_id=&query_fo rm_schema=permanent_queries&batch_input_file_id=&create_tmp_ data_tables=0">
>> >
>> >
>> >
>> > 72 rows have been returned by this query
>> >
>> > value='perm'>
>> > name='tmp_data_values_table'
>> > value='display.perm_tmp_data_values_518'>
>> > id='pg_query_form_id' name='pg_query_form_id' value='518'>
>> > type='hidden' id='query_form_schema' name='query_form_schema'
>> > value='permanent_queries'>
>> > name='data_table_id' value='255'>
>> > id='data_batch_id' name='data_batch_id' value='218'>
>> > type='hidden' id='batch_input_file_id' name='batch_input_file_id'
>> > value=''>
>> > value=''>
>> > value=''>
>> > name='data_table_type_id' value=''>
>> > name='user_name' value=''>
>> >
>> >
>> >
>> >
>>
>>
>
> Bit of advice though, don't use Javascript to submit a form. Firstly,
> Javascript isn't available on all browsers, and on those it is
> available on, not everyone has it turned on. The W3C has the stats for
> Javascript being unavailable in a browser at about 5%. Imagine that
> your site is only aimed at the population of the UK, 5% of 61 million
> is still over 3 million people. Obviously that doesn't take into
> consideration the ages of people who'd be using your site, but it's
> worth stopping and thinking about. Also, anyone using a mobile is
> unlikely to have Javascript enabled too, and a lot of people use
> mobiles these days for browsing and such whilst on the move.
>
> Secondly, you're using the onclick handler to submit a form. This is
> very bad, as you totally alienate anyone who visits your site that has
> a disability that prevents them using a mouse. So, anyone with hand
> problems like severe arthritis or missing hands, or anyone who is
> blind is shut out from your site.
>
> What you maybe ought to consider is using several submit buttons, and
> give each a name and a value. That way, your PHP script can check for
> a specifically named variable sent from the form. That way, you keep
> many people happy, and your site still works perfectly.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
--------------020202060004090309030307--
Re: PHP generated HTML has submit button which picks up thewrong url.
am 06.02.2010 03:06:52 von Robert Cummings
Joseph Thayne wrote:
> "What you maybe ought to consider is using several submit buttons, and
> give each a name and a value. That way, your PHP script can check for a
> specifically named variable sent from the form. That way, you keep many
> people happy, and your site still works perfectly."
>
> The problem with doing it that way is that IE is not happy with multiple
> submit buttons in a single form.
I've never seen IE have a problem with multiple submit buttons. I'm
guessing you're doing something wrong. I often have multiple submit buttons.
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: PHP generated HTML has submit button which picks up thewrong url.
am 06.02.2010 12:20:30 von Michael Peters
Ashley Sheridan wrote:
>
>
> Bit of advice though, don't use Javascript to submit a form. Firstly,
> Javascript isn't available on all browsers, and on those it is available
> on, not everyone has it turned on. The W3C has the stats for Javascript
> being unavailable in a browser at about 5%.
Yup.
Just the other day a company lost my business because after registering
for their web site, the login form did not work w/o JavaScript.
Interesting that the registration form itself did.
A freaking login form that had nothing but an e-mail address, password
field, and a button that was not a standard submit button, but a html
button elements with a JavaScript event attached to it.
There was no valid reason for them to require JavaScript for that, I do
not mind allowing JavaScript for local server if the site is of value to
me but the fact that they used JavaScript for a submit button in a form
that had two very standard fields told me that they did not know what
they are doing, indicating they probably did not have their site
properly protected from XSS injection, and I'm not going to white list a
web site that I have reason to suspect may not have proper server side
protection against XSS injection.
My guess is they don't even have a web master but are using some cms
that autogenerates everything for them, which probably means any input
validation is rather weak.
Use JavaScript when it is the best tool for the job. It is not the best
tool for form submission. Client side form validation, sure - it's nice
for catching problems before the user submits so he doesn't have to
submit again, but not for the submit action itself.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php