Re: Simple question

From: Date: Sun, 28 Dec 2003 22:07:15 +0000
Subject: Re: Simple question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-173403@lists.php.net to get a copy of this message
Hi Lab, I normally use code of the following format, which I think is quite neat: //Note that you do not need curely brackets in an "if" statement is there is only one line if ($_SERVER['REQUEST_METHOD'] == 'POST') $add = $HTTP_POST_VARS['textbox']; if ($add == 'Hello') do something //It is however recommended that you do the following in order to ensure that a user does not try to use malicious code in their input if ($_SERVER['REQUEST_METHOD'] == 'POST') $add = clean($HTTP_POST_VARS['textbox'], 20);; if ($add == 'Hello') do something where clean() is a function defined in an include as follows: function clean($input, $maxlength) { $input = substr($input, 0, $maxlength); $input = EscapeShellCmd($input); return ($input); } Hope that helps. Regards, Andy "Labunski" <romans@skulme.lv> wrote in message news:20031228211908.90707.qmail@pb1.pair.com... > Hello, I have only one simple question.. > I'm using this method to get the values from the text box: > > if(isset($_POST["Submit"]) && > $_POST["Submit"]=="Submit") > { > $add = $_POST['textbox'] ; > } > > But I don't know how to write the source for this: > > If the value from the textbox ($add) is "Hello" then.. do something. > I think it could be nicely done with IF, but I dont know how to write this.. > > Can someone help me, please? > > Regards, > Lab.

« previous php.general (#173403) next »