Hi, I have a question about the scope of a variable. I have two pages, one containing a form.
<form name="whatever" action="goon.php">
<input type="text" name="username">
</form>
Ok, it may not be the right syntax for the html, but you get the point. Anyway, in my goon.php file, I have something like this:
<?php
function checkname()
{
if( $username == "" )
echo "username is empty";
}
// main
checkname();
?>
Whatever I input in the form, its value is lost inside the function, thus "username is empty" is echoed. I've add a line echo $username; before the function, and at this point its value is still whatever I typed in.
So is this normal? That a variable passed from a form will lose its value inside a function? Thanks.