Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP 4.1.1 Global Arrays

Status
Not open for further replies.

WoodLark

Programmer
Jun 6, 2000
67
US
I am using PHP 4.1.1, Windows 2000 SP!, and
OHTTP version 2.09. I cannot get the global arrays to work unless register_globals is set to ON in php.ini. I thought their whole purpose was to eliminate the need for setting register_globals.

For example, the following code works if register_globals is ON, but fails if it is set to OFF.

<?php

print(&quot;\n&quot;);
print(&quot;<HEAD>\n&quot;);
print(&quot;<TITLE>Index.php</TITLE>\n&quot;);
print(&quot;</HEAD>\n&quot;);
print(&quot;<BODY>\n&quot;);

if ($stage == 0)
{
print(&quot;<FORM ACTION=\&quot;$PHP_SELF\&quot; METHOD=\&quot;POST\&quot; &quot;);

// Set up input field for first name
print(&quot;<LABEL FOR=\&quot;FName\&quot;>First Name: </LABEL>\n&quot;);
print(&quot;<INPUT &quot;);
print(&quot;TYPE=\&quot;text\&quot; &quot;);
print(&quot;NAME=\&quot;FName\&quot; &quot;);
print(&quot;VALUE=&quot;);
print($_REQUEST[&quot;F1Name&quot;]);
print(&quot;>\n&quot;);

// Set up input field for last name
print(&quot;<LABEL FOR=\&quot;LName\&quot;>Last Name: </LABEL>\n&quot;);
print(&quot;<INPUT &quot;);
print(&quot;TYPE=\&quot;text\&quot; &quot;);
print(&quot;NAME=\&quot;LName\&quot; &quot;);
print(&quot;VALUE=&quot;);
print($_REQUEST[&quot;L1Name&quot;]);
print(&quot;>\n&quot;);

// Set up hidden input field for stage
print(&quot;<INPUT &quot;);
print(&quot;TYPE=\&quot;hidden\&quot; &quot;);
print(&quot;NAME=\&quot;stage\&quot; &quot;);
print(&quot;VALUE=1>\n&quot;);

// Set up submit button
print(&quot;<INPUT &quot;);
print(&quot;TYPE=\&quot;submit\&quot; &quot;);
print(&quot;NAME=\&quot;Submit_Button\&quot; &quot;);
print(&quot;VALUE=\&quot;Try It\&quot;>\n&quot;);

print(&quot;</FORM>\n&quot;);

}
else
{
if ($FName==&quot;&quot; OR $LName==&quot;&quot;)
{
print(&quot;<P>You must enter a complete name.</P>\n&quot;);

print(&quot;<FORM ACTION=\&quot;$PHP_SELF\&quot; METHOD=\&quot;POST\&quot; &quot;);

// Set up hidden field for first name
print(&quot;<LABEL FOR=\&quot;F1Name\&quot;></LABEL>\n&quot;);

print(&quot;<INPUT &quot;);
print(&quot;TYPE=\&quot;hidden\&quot; &quot;);
print(&quot;NAME=\&quot;F1Name\&quot; &quot;);
print(&quot;VALUE=&quot;);
print($_REQUEST[&quot;FName&quot;]);
print(&quot;>\n&quot;);

// Set up hidden field for last name
print(&quot;<INPUT &quot;);
print(&quot;TYPE=\&quot;hidden\&quot; &quot;);
print(&quot;NAME=\&quot;L1Name\&quot; &quot;);
print(&quot;VALUE=&quot;);
print($_REQUEST[&quot;LName&quot;]);
print(&quot;>\n&quot;);

// Set up hidden input field for stage
print(&quot;<INPUT &quot;);
print(&quot;TYPE=\&quot;hidden\&quot; &quot;);
print(&quot;NAME=\&quot;stage\&quot; &quot;);
print(&quot;VALUE=0>\n&quot;);

// Set up submit button
print(&quot;<INPUT &quot;);
print(&quot;TYPE=\&quot;submit\&quot; &quot;);
print(&quot;NAME=\&quot;Retry_Button\&quot; &quot;);
print(&quot;VALUE=\&quot;Re-Try\&quot;>\n&quot;);

print(&quot;</FORM>\n&quot;);

}
else
{
print(&quot;You entered: &quot; . $FName . &quot; &quot; . $LName);
}
}

print(&quot;</BODY>\n&quot;);
print(&quot;\n&quot;);

Can anybody suggest what I might be doing wrong?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top