Hi,
I'm using version 4.0.6 before and i recently upgraded my version to 4.2 and now everything isn't working. I know that they turned the register_global off and i'm reading a lot of the alternatives but when I tried it myself it doesn't seem to work. Can somebody look at this code:
How come i'm getting notice like undefined variable submit?
Thanks in advance. I really need to figure out the problem.
-------------------------------------------------------------------------------------
<?php
$PHP_SELF = $_SERVER['PHP_SELF'];
//Handle Input here
//Check if $submit has a value of "Go" - The Validator
if($submit=="Go"){
//The Processor
echo("You wrote ".$_POST["you_wrote"]);
echo("<br>You could have done whatever you want with the input instead");
exit;
}
?>
<!-- The Frontend HTML form -->
<form action="<?php echo $PHP_SELF ?>" method="POST" >
<p>Input a word <input type="text" size="20" name="you_wrote">
<input type="submit" name="submit" value="Go"></p>
</form>
-------------------------------------------------------------------------------------
Can't pass variable from forms : PHP Version 4.2
Moderator: General Moderators
Why not just try:
should work... or at least that's how I do it
Though I never use a value for submit... does that work?
Code: Select all
if ($submit == "Go"){
echo "you wrote $you_wrote";
echo "<br>You could have done whatever you want with the input instead";
}why checking for post-data at all?
$_REQUEST['submit'] $_REQUEST['you_wrote'] should contain the values wether they were posted or passed by GET.
Since I hate to ignore all the warnings in my apache-log I check the existence of the key before trying to access it
if (array_key_exists('submit', $_REQUEST) && strcmp($_REQUEST['submit'], 'GO')==0) .....
F*** the performance
$_REQUEST['submit'] $_REQUEST['you_wrote'] should contain the values wether they were posted or passed by GET.
Since I hate to ignore all the warnings in my apache-log I check the existence of the key before trying to access it
if (array_key_exists('submit', $_REQUEST) && strcmp($_REQUEST['submit'], 'GO')==0) .....
F*** the performance
cathari:
change to
Code: Select all
if($submit=="Go"){Code: Select all
if(isset($_POSTї'submit'])){It worked!!!
Thanks a lot. I did some modifications on
and it worked just fine.
Thanks a lot. I did some modifications on
Code: Select all
echo("You wrote ".$_Postї'you_wrote']);
To
echo("You wrote ".$_REQUESTї'you_wrote']);