Why doesn't this work?

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
xarzu
Forum Newbie
Posts: 4
Joined: Fri May 25, 2007 2:20 pm

Why doesn't this work?

Post 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?
Last edited by califdon on Sun Feb 06, 2011 10:13 pm, edited 1 time in total.
Reason: Moderator edited to change "code" tags to "syntax=php" tags.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Why doesn't this work?

Post 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
Post Reply