Register Gobals and Arrays?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Mr Tech
Forum Contributor
Posts: 424
Joined: Tue Aug 10, 2004 3:08 am

Register Gobals and Arrays?

Post by Mr Tech »

This is my code:

Code: Select all

<?php
if ($_POST&#1111;'submit']) &#123;

//check each custom&#1111;] field
foreach($custom as $check) &#123;
if ($check == "") &#123;
$err = "yes";
&#125;
&#125;

if ($err) &#123;
//display error
echo "Error";
&#125; else &#123;
//display thankyou page
echo "All fields entered";
&#125;

&#125; else &#123;
?>
<form action="errorcheck.php" method="post">
<input type="text" name="custom&#1111;1]"><br> 
<input type="text" name="custom&#1111;2]"><br> 
<input type="text" name="custom&#1111;3]"><br>
<input type="submit" name="submit" value="Submit">
</form>
<?php
&#125;
?>
My only problem is register globals... I tried adding this:

Code: Select all

foreach($HTTP_GET_VARS&#1111;custom] as $check) &#123;
But I get an error. Can anyone shed some light on this?

Cheers.
User avatar
Mr Tech
Forum Contributor
Posts: 424
Joined: Tue Aug 10, 2004 3:08 am

Post by Mr Tech »

OK, it looks like I found it... I dont get any errors:

$GLOBALS['custom']

Is that correct/best way to do it?

http://au.php.net/variables.predefined
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

$_POST['custom']
User avatar
Mr Tech
Forum Contributor
Posts: 424
Joined: Tue Aug 10, 2004 3:08 am

Post by Mr Tech »

LOL, I can't beleive I missed that. Cheers mate. I appreciate the help ;)
Post Reply