LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-09-2003, 05:16 PM   #1
raypen
Member
 
Registered: Jun 2002
Location: Midwest
Distribution: Slackware
Posts: 365

Rep: Reputation: 30
Another register_globals question


I thought I understood the implications of setting
register_globals to off, but further study has got me
somewhat confused. Although I have read this dicsussion
of this topic on the PHP website:

http://www.php.net/manual/en/printwn...terglobals.php

I have run across a problem which I can't seem to fathom.

The simple script below works to demonstrate the use of
global variables:

<html>
<body>

<?php

function showform() {
global $variable1, $proof;
$proof='<hr>Proof Of Concept!';
echo '<form method="get">';
echo '<hr>';
echo '<input type="text" size="25" name="variable1"
value="'.$variable1.'">';
echo '<br>';
echo '<input type="submit" value="TESTME!">';
echo '</form>';

if ( isset($variable1) ) {
// if it DOES exist
echo $variable1.'<br>';
}
else {
// if it does NOT exist
echo 'Missing $variable1<br>';
}

showform();

// I threw this in to illustrate a point I made earlier while
// rambling...
echo $proof;

?>

</body>
</html>

The statement 'Missing $variable1' always prints before the
form appears and "Proof of Concept' appears
just below the form when 'echo $proof;' is encountered.

However, I can't enter anything in the form to set $variable1;
'Missing $variable1' still appears even if I use:

if ( isset($_GET['variable1']) )

Apparently, the variable is not being set.

1. Why isn't the variable set?

2. Why does echo $proof work when I should be using
echo $_GET['proof']; if register_globals is off?

I seem to be missing something, but I think it is fundamental
to my understanding of how variables work.

TIA
 
Old 06-12-2003, 07:04 AM   #2
j-ray
Senior Member
 
Registered: Jan 2002
Location: germany
Distribution: ubuntu, mint, suse
Posts: 1,591

Rep: Reputation: 145Reputation: 145
your form does not contain an action tag
<form action="script.php" method="...
maybe that's all
cheers, jens
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Question, Apples Contribution to Open Source + MacOs file structure question Higgy3k Other *NIX 5 07-25-2005 04:23 AM
Not your regular GRUB question - just a short question for a fried MBR!! ziphem Linux - General 3 01-31-2005 01:51 PM
Question on register_globals in PHP vharishankar Programming 4 11-22-2004 08:23 PM
PHP and IIS qith register_globals Dax_wells Linux - Software 0 11-04-2004 08:49 AM
login prompt question & kde scheme question JustinCoyan Slackware 2 06-09-2004 02:02 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:37 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration