Page 1 of 1

Why doesn't this work?

Posted: Sun Feb 06, 2011 9:24 pm
by xarzu
Why doesn't this work?

Code: Select all

<?php
    if ($_POST['textbox1'] != "")
		$_ENV['mytestzeststring'] = $_POST['textbox1'];
	print $_ENV['mytestzeststring'];
?>

<form name="registerform" id="registerform" action="<?php echo site_url('wp-login.php?action=register', 'login_post') ?>" method="post">
	  <input type="text" name="testbox1"/>
	  <input type="submit" value="Click me!"/>

</form>
Wouldn't this present on the page before the form declaration whatever the user types in the test box?

Re: Why doesn't this work?

Posted: Sun Feb 06, 2011 10:19 pm
by califdon
$_ENV variables are system environment variables. As far as I know, you can't define your own. What you should be doing is using $_SESSION variables. Note that every script that either writes to, or reads from $_SESSION variables MUST issue the php command:
session_start();
in the script before anything (even a blank line) is sent to the browser.

Ref.: http://www.php.net/manual/en/reserved.v ... ession.php