If... Else.. I'm not getting it!

From: Date: Sat, 25 Jan 2003 09:12:56 +0000
Subject: If... Else.. I'm not getting it!
Groups: php.dev 
Request: Send a blank email to php-dev+get-93664@lists.php.net to get a copy of this message
Hi all, Please can you help me with the following: If got a little sample code: This one is working (!): <?php $vname=$_POST['vname']; echo "hello $vname"; ?> <form action="<? echo ($_SERVER['PHP_SELF']); ?>" method=post> <table> <tr><td>Input yourname</td><td><input type=text name=vname></td></tr> <tr><td colspan=2><input type=submit name=submit></td></tr> </table> </form> <?php ?> But when i'm using IF Else.. Nothing is happening. I'm only seeing the form but when i submit that form: The $vname doen't display.. Here is the code that doesn't work: <?php $vname=$_POST['vname']; if($submit) { echo "hello $vname"; } else { ?> <form action="<? echo ($_SERVER['PHP_SELF']); ?>" method=post> <table> <tr><td>Input yourname</td><td><input type=text name=vname></td></tr> <tr><td colspan=2><input type=submit name=submit></td></tr> </table> </form> <?php } ?> What am I doing wrong??? Thanks, Frank

« previous php.dev (#93664) next »