By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,401 Members | 1,702 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,401 IT Pros & Developers. It's quick & easy.

Multiple submits broken in PHP5

P: n/a
I have a page with multiple submit buttons. Call them "ok" and
"cancel". I have the coding in PHP as:

if (isset($ok)) { something } and if (isset($cancel)) { something
else }

This works fine in PHP 4.X. In PHP5 it doesn't work at all (no action
at all). What is the replacement coding and how can I code so that it
works in all versions of PHP?

Shelly

Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On 26 May 2005 04:51:49 -0700, sh*******@asap-consult.com wrote:
I have a page with multiple submit buttons. Call them "ok" and
"cancel". I have the coding in PHP as:
if (isset($ok)) { something } and if (isset($cancel)) { something
else }


Oh man. http://php.net/manual/en/security.globals.php
--
Firefox Web Browser - Rediscover the web - http://getffox.com/
Thunderbird E-mail and Newsgroups - http://gettbird.com/
Jul 17 '05 #2

P: n/a
It should be noted that this is not an issue of PHP 4 versus 5, but rather
of different configurations (php.ini files).

You are able to access $ok and $cancel because they are automatically set as
global variables in your PHP 4 config. You should disable this - only
goodwill can stop me from submitting a form with a field called "query" set
to drop all your databases...

To do so, open your php.ini file (probably located in your PHP folder or
your Windows folder - on Windows) and change the line that reads:

register_globals = On

to

register_globals = Off

Now, you not be able to access $ok or $cancel directly - instead, you can
access them through the $_GET or $_POST arrays(depending on your form
method). For example, if your form method is POST, then you can use this:

if (isset($_POST["ok"])) { something } and if (isset($_POST["$cancel"]))
{ something else }

ECRIA
http://www.ecria.com
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.