Bug #18215 Updated: Notice: Undefined variable: submit in C:\
| From: | philip@php.net | Date: | Tue, 09 Jul 2002 17:56:31 +0000 |
| Subject: | Bug #18215 Updated: Notice: Undefined variable: submit in C:\ | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-13631@lists.php.net to get a copy of this message | ||
ID: 18215
Updated by: philip@php.net
Reported By: orraco@hotmail.com
Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Win2000
PHP Version: 4.2.1
New Comment:
You have register_globals enabled and $submit may exist if the form is
submitted (although not all browsers/situations pass the submit button,
like sometimes when pressing enter). Anyway, use a check like isset()
otherwise an error of level E_NOTICE is created if a variable doesn't
exist. Example:
print $undefined; // E_NOTICE error
if ($undefined) // E_NOTICE error
if (isset($undefined)) { // No E_NOTICE error
I would suggest putting something like the following in your code:
<input type="hidden" name="action" value="form_submitted">
See also: error_reporting(), empty() and error handling.
Am adding a faq on this now.
Previous Comments:
------------------------------------------------------------------------
[2002-07-09 10:46:10] orraco@hotmail.com
Anyone help with this ?
------------------------------------------------------------------------
[2002-07-08 03:52:54] orraco@hotmail.com
I have already tried the 'register_globals' setting although I have
read that it is set this way for a reason in other articles. I notice
from looking around that other people are having similar errors, and
are having great difficulty in finding a solution.
But even with the change I don't get an output..... Any ideas??
------------------------------------------------------------------------
[2002-07-07 18:44:03] jan@php.net
In PHP 4.2.0, the 'register_globals' setting default changed to
be off. See http://www.php.net/release_4_2_0.php
for more info.
We are sorry about the inconvenience, but this change was a necessary
part of our efforts to make PHP scripting more secure and portable.
------------------------------------------------------------------------
[2002-07-07 18:41:20] orraco@hotmail.com
Although new to PHP I have been testing a few web Utilities.
I have downloaded some'code that provides a ping function. I have
tested my PHP install to the best of my knowledge its correct but still
recieve an error Notice: Undefined variable: submit in C:\Documents and
Settings\Administrator\My Documents\My Webs\php-ping.php on line 14
I have been testing on a local machine running Windows NT 5.0 build
2195 and Microsoft-IIS/5.0 the code is as follows
<?php
// This script was writen by webmaster@theworldsend.net, Aug. 2001
// http://www.theworldsend.net
// This is my first script. Enjoy.
//
// Put it into whatever directory and call it. That's all.
//
//-------------------------
$max_count = "10"; //maximum count for ping command
$os = "win"; // win or unix (unix means all flavors of linux as
well)
// -------------------------
//
// nothing more to be done.
If ($submit == "Ping!") {
If ($count > $max_count)
{
echo 'Maximum for count is '.$max_count;
echo '<a href="php-ping.php">Back</a>';
$again = True;
}
else
{
If (ereg(" ",$host))
{
echo 'No Space in Host field allowed !';
echo '<a href="php-ping.php">Back</a>';
$again= True;
}
else
{
echo("Ping Output:<br>");
echo("<pre>");
$host = escapeshellarg($host);
$count = escapeshellarg($count);
if ($os =="win")
{
system("ping -n $count $host", $list);
}
else
{
system("ping -t $count $host", $list);
};
echo("</pre>");
}
}
}
else
{
echo '
<html><body>
<form methode="post" action="php-ping.php">
Enter IP or Host <input type="text" name="host"></input>
Enter Count <input type="text" name="count" size="2"
value="4"></input>
<input type="submit" name="submit"
value="Ping!"></input>
</form>
</body></html>';
}
?>
Please can you help I have tried all that I can think of. I can remove
the error message via php.ini but would like it to work and return a
value.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=18215&edit=1