Re: Simple PHP script

From: Date: Thu, 13 Feb 2003 21:40:35 +0000
Subject: Re: Simple PHP script
Groups: php.general 
Request: Send a blank email to php-general+get-135527@lists.php.net to get a copy of this message
In a message dated 2/13/2003 1:11:35 PM Pacific Standard Time, kpoon@infomart.ca writes: >I am new to PHP and had just written a simple php script to get things >started. I have the following code: > ><?php >if($submit1) { >echo "hello $vname"; >} else { >?> ><form action="thispage.php" method=post> > >Input yourname<input type=text name=vname> > ><input type=submit name=submit1> > > ></form> ><?php >} >?> >So this page is suppose to display a input box and a submit button and once >you enter ur name and press the button, it should show Hello [ur name] and >the input box at the bottom of it and the button below and the process >continue. > >I tried running it and inputted some text and pressed the button, and the >Hello [ur name] didn't show up, it just display an input box and the submit >button. > My guess would be that you have register_globals = Off. You can change it to register_globals = On in your php.ini file. But it would be better to learn to program with globals turned off. The following program would run correctly. <?php if($_POST['submit1']) { echo "hello {$_POST['vname']}"; } else { ?> <form action="thispage.php" method="post"> Input yourname<input type="text" name=vname> <input type="submit" name="submit1"> </form> <?php } ?> Janet ------------------------------- Janet Valade Author, PHP & MySQL for Dummies

« previous php.general (#135527) next »