On 29 Oct 2002 at 9:41, Mukta Telang wrote:
> I have written followong code in hello.html: > <FORM ACTION=hello.php METHOD=POST> > <INPUT TYPE=TEXTAREA NAME=textbox> > <?php > printf("<BR>hello %s!",$textbox); > ?> > This script works fine with php in redhat 7.2 system > but does not work in solaris 7 ! > > I have done the php installation... > What are the chances that the problem is with the php-installation? ( I > had to copy code from apache2filter directory of pre 4.3 version of php > to remove errors during make ) > > I tried using echo($_GET['$textbox']) instead of printf statement in > hello.php.. I tried to snip the above to keep only the necessary. I think you might try using some existing scripts that you know work and then understand why they work. Keep the orginals, make some changes and if something breaks you have the original and you can probably see what you did to break it. This is what I usually do with a new language and only later, sometimes, do I begin to understand the why. I'm learning assembly now and the author tells me I cannot do this with assembly :), I'll see. Couple of things: Perhaps it's a case of globals being off so $textbox doesn't (thank goodness) spring into existence. See the php site: http://www.php.net/manual/en/security.registerglobals.php A VERY helpful site. Check your php.ini file. Run phpinfo() in a script and you'll see the location of your ini file and whether globals are turned on or off. You Use POST in the form but then use $_GET, that should seem odd to you. You also use $_GET['$textbox'] when it should have used $_POST['textbox'], I think, I never use this method, check the php.net site, you can download the documentation.. I personally have a simple function where I put all my user input an array and it matters not whether post or get is used. Here is another example of your hello.html and hello.php. I also highly, highly recommend you look at using Smarty as a templating system. As far as PHP uses OO I suggest you use it (I personally find OO type apps much easier to debug than stream of consciousness types, even my own); hell.html (I apologize for not improving the html) <HTML> <HEAD> </HEAD> <BODY> <FORM ACTION=hello.php METHOD=POST> <B>enter your name:</B> <INPUT TYPE=TEXTAREA NAME=textbox> <INPUT TYPE=SUBMIT> </FORM> </BODY> </HTML> hello.php <? $input =& ProcessFormData($GLOBALS); function &ProcessFormData(&$GLOBAL_INPUT) { $FormVariables = array(); $input = $GLOBAL_INPUT['HTTP_GET_VARS'] ? $GLOBAL_INPUT['HTTP_GET_VARS'] : $GLOBAL_INPUT['HTTP_POST_VARS']; foreach($input as $Key=>$Value) { if(is_array($Value)) { foreach($Value as $SubKey=>$SubValue) { $FormVariables[$Key][$SubKey] = $SubValue; } }else { $FormVariables[$Key] = $Value; } } # End of foreach return $FormVariables; } # End ProcessFormData ?> <HTML> <HEAD><title>Hello <? echo $input['textbox']; ?></title></HEAD> <BODY> <?php printf("<BR>hello %s!",$textbox); print "<pre>"; print_r($input); print "</pre>"; ?> </BODY> </HTML> __end Of course I'd put the ProcessFormData in some included file, not in a php file as such. Peter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php