php-general Digest 20 Feb 2013 12:42:05 -0000 Issue 8130
php-general Digest 20 Feb 2013 12:42:05 - Issue 8130 Topics (messages 320246 through 320256): Re: parsing select multiple=multiple 320246 by: Jim Giner Re: [PHP-DEV] PHP 5.3.22RC1 and 5.4.12RC1 Released for Testing! 320247 by: Jan Ehrhardt 320248 by: Johannes Schlüter 320249 by: Stas Malyshev 320250 by: Jan Ehrhardt phpinfo() 320251 by: John Taylor-Johnston 320254 by: Ashley Sheridan 320256 by: Design in Motion Webdesign if (empty versus if (isset 320252 by: John Taylor-Johnston 320253 by: Adam Richardson 320255 by: marco.behnke.biz Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- On 2/19/2013 2:02 PM, John Taylor-Johnston wrote: tamouse mailing lists wrote: I hate arrays. :D Here's a small snippet showing how it works, I hope: foreach ($DPRpriority as $item = $value) { echo li .$item.: .$value['name']. selected: .$value['selected']. /li\n; } Question 1: when did we have to add [] to a input name to turn it into an array? input type=checkbox name=DPRlocationdetails[] value=Unknown According to phpinfo() it still comes out as $_POST['DPRlocationdetails'] without []. Are the [] necessary? -- Question 2: I was looking at some code in the Manual, where someone used isset and is_array. How necessary is if(isset($_POST['DPRlocationdetails'])) and then to use: if(is_array($_POST['DPRlocationdetails'])) That seems like over kill? -- Question 3: My code works, perfectly. In this case, I decided to attack some check-boxes first. The resulting function will work for select multiple too.. Does anyone see me doing something wrong in my code below? My questions are: Is this the only way to pass Unknown, Family Home or Apartment into the function? Is this correct? if ($_POST['DPRlocationdetails'] == Unknown) Somebody once told me I had to do it this way? if (Unknown == $_POST['DPRlocationdetails']) John snip--- form action=foo.php id=DPRform method=postinput value=Update type=submit input type=checkbox name=DPRlocationdetails[] value=Unknown ?php filter_value($_POST['DPRlocationdetails'],Unknown); ? Unknown input type=checkbox name=DPRlocationdetails[] value=Family Home ?php filter_value($_POST['DPRlocationdetails'],Family Home); ? Family Home input type=checkbox name=DPRlocationdetails[] value=Apartment ?php filter_value($_POST['DPRlocationdetails'],Apartment); ? Apartment /form ?php function filter_value($tofilter,$tofind) { foreach($tofilter as $value){ if ($value == $tofind) echo checked; } } ? The [] are necessary if there are going to be multiple occurrences of an input with the same name, hence the [] to allow your php script to extract all of the occurrences. Using isset and is_array comes in handy to help you handle the incoming var properly. If it IS set, you then have to check if there is only one value (hence a string) or if there are multiple values (an array). #3 - no idea what you are asking. ---End Message--- ---BeginMessage--- Johannes Schlüter in php.internals (Thu, 31 Jan 2013 16:00:17 +0100): If no critical issues is found in this RC, the final version will be released in two weeks. Just curious: what is keeping 5.3.22 and 5.4.12 from being released? Are there any issues? Jan ---End Message--- ---BeginMessage--- On Wed, 2013-02-20 at 00:13 +0100, Jan Ehrhardt wrote: Johannes Schlüter in php.internals (Thu, 31 Jan 2013 16:00:17 +0100): If no critical issues is found in this RC, the final version will be released in two weeks. Just curious: what is keeping 5.3.22 and 5.4.12 from being released? Are there any issues? As a look on qa.php.net or the box on the top right of php.net tells we have RC2 for both out, you can also see in the repo that the release is being prepared: http://git.php.net/?p=php-src.git;a=blobdiff;f=NEWS;h=d3a3e9fa0f344d9b736ea17ce408df6b02e8b561;hp=c4262020de69b7a93b8fcf4923e85194756435a7;hb=0183c29cb3921926855ed6f5e7cea7851fb8a5a1;hpb=904d2202eaecb7c300c36f37ebc5503513220c09 Please test the RCs and provide test feedback. Thanks. johannes ---End Message--- ---BeginMessage--- Hi! Johannes Schlüter in php.internals (Thu, 31 Jan 2013 16:00:17 +0100): If no critical issues is found in this RC, the final version will be released in two weeks. Just curious: what is keeping 5.3.22 and 5.4.12 from being released? Are there any issues? We had 5.4.12 RC2 last week, due to recent SOAP fixes we had to pull in, and will have 5.4.12 GA this week. -- Stanislav Malyshev, Software
php-general Digest 21 Feb 2013 06:17:15 -0000 Issue 8131
php-general Digest 21 Feb 2013 06:17:15 - Issue 8131 Topics (messages 320257 through 320274): Re: if (empty versus if (isset 320257 by: Jim Giner 320258 by: marco.behnke.biz 320259 by: Tedd Sperling Re: phpinfo() 320260 by: Tedd Sperling 320269 by: John Taylor-Johnston 320270 by: Ashley Sheridan 320271 by: Stuart Dallas 320273 by: Tedd Sperling 320274 by: tamouse mailing lists Re: parsing select multiple=multiple 320261 by: Tedd Sperling 320262 by: Jim Giner stripped \n 320263 by: John Taylor-Johnston 320264 by: Jim Giner 320265 by: Matijn Woudt 320266 by: Daniel Brown 320267 by: Jim Giner 320268 by: Ashley Sheridan 320272 by: Jim Lucas Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- Basically it tells a savvy programmer whether or not his logic has caused the var in question to exist. Many times it is important simply to know that, not what the var contains, which can lead to an error in processing. The isset() will tell you that yes, I have this variable, letting you then correctly interpret the contents. If a $_POST var is not set (meaning the user made no input to it), the use of empty() will insist on telling you that the var is empty even tho it really was not provided by the user (assuming that you don't get an error msg for having an invalid index in the POST array). They seem to be needlessly redundant, but in fact do provide knowledge for those seeking it. ---End Message--- ---BeginMessage--- Jim Giner jim.gi...@albanyhandball.com hat am 20. Februar 2013 um 15:10 geschrieben: Basically it tells a savvy programmer whether or not his logic has caused the var in question to exist. Many times it is important simply to know that, not what the var contains, which can lead to an error in processing. The isset() will tell you that yes, I have this variable, letting you then correctly interpret the contents. If a $_POST var is not set (meaning the user made no input to it), the use of empty() will insist on telling you that the var is empty even tho it really was not provided by the user (assuming that you don't get an error msg for having an invalid index in the POST array). keep in mind that isset returns false if the variable exists, but has a value of null. The same applies to existing array keys with value null. They seem to be needlessly redundant, but in fact do provide knowledge for those seeking it. No, they are not as I wrote in my last message -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Marco Behnke Dipl. Informatiker (FH), SAE Audio Engineer Diploma Zend Certified Engineer PHP 5.3 Tel.: 0174 / 9722336 e-Mail: ma...@behnke.biz Softwaretechnik Behnke Heinrich-Heine-Str. 7D 21218 Seevetal http://www.behnke.biz ---End Message--- ---BeginMessage--- On Feb 20, 2013, at 9:10 AM, Jim Giner jim.gi...@albanyhandball.com wrote: Basically it tells a savvy programmer whether or not his logic has caused the var in question to exist. Many times it is important simply to know that, not what the var contains, which can lead to an error in processing. The isset() will tell you that yes, I have this variable, letting you then correctly interpret the contents. If a $_POST var is not set (meaning the user made no input to it), the use of empty() will insist on telling you that the var is empty even tho it really was not provided by the user (assuming that you don't get an error msg for having an invalid index in the POST array). They seem to be needlessly redundant, but in fact do provide knowledge for those seeking it. That's one of the reason why I recommend using a Ternary Operator to check the POST array, such as: $submit = isset($_POST['submit']) ? $_POST['submit'] : null; That way, you never encounter an error looking for something that is not there. Cheers, tedd t...@sperling.com http://sperling.com ---End Message--- ---BeginMessage--- On Feb 19, 2013, at 7:57 PM, John Taylor-Johnston john.taylor-johns...@cegepsherbrooke.qc.ca wrote: I cannot find button2 in phpinfo() when I click it. I was hoping to find a $_POST[button2] value. What am I doing wrong? input type=button name=button2 id=button2 value=Print Mode onclick=formSubmit() I really wanted to use a button to pass a different condition than a input type=submit Lot's of different ways to pass values via forms. Try using : input type=hidden name=button2 value=2 Then check the button2 value via a:
Re: [PHP] if (empty versus if (isset
isset checks if something is defined or if an array has a key with a value other than null read: http://www.php.net/manual/en/function.isset.php#refsect1-function.isset-returnvalues empty check isset PLUS if the value is not null, false, 0 and wahtever php thinks is empty read: http://www.php.net/manual/en/function.empty.php#refsect1-function.empty-returnvalues You should also checkout array_key_exists read: http://www.php.net/manual/en/function.array-key-exists.php John Taylor-Johnston john.taylor-johns...@cegepsherbrooke.qc.ca hat am 20. Februar 2013 um 03:29 geschrieben: What is the difference between? if (empty... http://www.php.net/manual/en/function.empty.php Determine whether a variable is empty and if (isset... http://php.net/manual/en/function.isset.php Determine if a variable is set and is not *|NULL|* I have an input type=radio value=something. If it is not checked, it is NOT empty, because it has a value, right? But it is NOT set, right? Is this empty, because it's value is ? input type=text value= Just trying to understand ... :) -- Marco Behnke Dipl. Informatiker (FH), SAE Audio Engineer Diploma Zend Certified Engineer PHP 5.3 Tel.: 0174 / 9722336 e-Mail: ma...@behnke.biz Softwaretechnik Behnke Heinrich-Heine-Str. 7D 21218 Seevetal http://www.behnke.biz -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] phpinfo()
John Taylor-Johnston john.taylor-johns...@cegepsherbrooke.qc.ca wrote: I cannot find button2 in phpinfo() when I click it. I was hoping to find a $_POST[button2] value. What am I doing wrong? input type=button name=button2 id=button2 value=Print Mode onclick=formSubmit() I really wanted to use a button to pass a different condition than a input type=submit Use a different value or name on the input type=submit/ button. Don't use JavaScript to trigger the form like that. Its not necessary and will bite you in the ass if ypu get a visitor who browses without JavaScript, which can include security aware users, blind users, etc Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Try $_POST['button2'] Best regards. Steven -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: if (empty versus if (isset
Basically it tells a savvy programmer whether or not his logic has caused the var in question to exist. Many times it is important simply to know that, not what the var contains, which can lead to an error in processing. The isset() will tell you that yes, I have this variable, letting you then correctly interpret the contents. If a $_POST var is not set (meaning the user made no input to it), the use of empty() will insist on telling you that the var is empty even tho it really was not provided by the user (assuming that you don't get an error msg for having an invalid index in the POST array). They seem to be needlessly redundant, but in fact do provide knowledge for those seeking it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: if (empty versus if (isset
Jim Giner jim.gi...@albanyhandball.com hat am 20. Februar 2013 um 15:10 geschrieben: Basically it tells a savvy programmer whether or not his logic has caused the var in question to exist. Many times it is important simply to know that, not what the var contains, which can lead to an error in processing. The isset() will tell you that yes, I have this variable, letting you then correctly interpret the contents. If a $_POST var is not set (meaning the user made no input to it), the use of empty() will insist on telling you that the var is empty even tho it really was not provided by the user (assuming that you don't get an error msg for having an invalid index in the POST array). keep in mind that isset returns false if the variable exists, but has a value of null. The same applies to existing array keys with value null. They seem to be needlessly redundant, but in fact do provide knowledge for those seeking it. No, they are not as I wrote in my last message -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Marco Behnke Dipl. Informatiker (FH), SAE Audio Engineer Diploma Zend Certified Engineer PHP 5.3 Tel.: 0174 / 9722336 e-Mail: ma...@behnke.biz Softwaretechnik Behnke Heinrich-Heine-Str. 7D 21218 Seevetal http://www.behnke.biz -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] if (empty versus if (isset
On Feb 20, 2013, at 9:10 AM, Jim Giner jim.gi...@albanyhandball.com wrote: Basically it tells a savvy programmer whether or not his logic has caused the var in question to exist. Many times it is important simply to know that, not what the var contains, which can lead to an error in processing. The isset() will tell you that yes, I have this variable, letting you then correctly interpret the contents. If a $_POST var is not set (meaning the user made no input to it), the use of empty() will insist on telling you that the var is empty even tho it really was not provided by the user (assuming that you don't get an error msg for having an invalid index in the POST array). They seem to be needlessly redundant, but in fact do provide knowledge for those seeking it. That's one of the reason why I recommend using a Ternary Operator to check the POST array, such as: $submit = isset($_POST['submit']) ? $_POST['submit'] : null; That way, you never encounter an error looking for something that is not there. Cheers, tedd t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] phpinfo()
On Feb 19, 2013, at 7:57 PM, John Taylor-Johnston john.taylor-johns...@cegepsherbrooke.qc.ca wrote: I cannot find button2 in phpinfo() when I click it. I was hoping to find a $_POST[button2] value. What am I doing wrong? input type=button name=button2 id=button2 value=Print Mode onclick=formSubmit() I really wanted to use a button to pass a different condition than a input type=submit Lot's of different ways to pass values via forms. Try using : input type=hidden name=button2 value=2 Then check the button2 value via a: $button2 = isset($_POST['button2']) ? $_POST['button2'] : null; That's one way -- there are many more. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] parsing select multiple=multiple
On Feb 18, 2013, at 7:54 PM, John Taylor-Johnston john.taylor-johns...@cegepsherbrooke.qc.ca wrote: I am capable with select name=DPRpriority. (I suppose I did it correctly? :p ) But I haven't the first clue how to parse a select multiple and multiply select name=DPRtype. Would anyone give me a couple of clues please? :) Thanks, John John: A clue? How about an example? See here: http://sperling.com/php/select/index.php Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] parsing select multiple=multiple
On 2/20/2013 11:41 AM, Tedd Sperling wrote: On Feb 18, 2013, at 7:54 PM, John Taylor-Johnston john.taylor-johns...@cegepsherbrooke.qc.ca wrote: I am capable with select name=DPRpriority. (I suppose I did it correctly? :p ) But I haven't the first clue how to parse a select multiple and multiply select name=DPRtype. Would anyone give me a couple of clues please? :) Thanks, John John: A clue? How about an example? See here: http://sperling.com/php/select/index.php Cheers, tedd _ t...@sperling.com http://sperling.com Try googling it. It's out there. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] stripped \n
Hi, I have a textarea when submitted creates a new form with the textarea data in a hidden field: input name=DPRnarration type=text hidden form=DPRform value=Enter call narration here. But when this new form gets resubmitted, the \n get stripped? input name=DPRnarration type=text hidden form=DPRform value=Enter callnarration here. I don't get it. There is nothing in my code that is stripping the \n? input name=DPRnarration type=text hidden form=DPRform value=?php echo stripslashes($_POST[DPRnarration]);? Do I need to put it in another textarea and declare it hidden?
[PHP] Re: stripped \n
On 2/20/2013 1:16 PM, John Taylor-Johnston wrote: Hi, I have a textarea when submitted creates a new form with the textarea data in a hidden field: input name=DPRnarration type=text hidden form=DPRform value=Enter call narration here. But when this new form gets resubmitted, the \n get stripped? input name=DPRnarration type=text hidden form=DPRform value=Enter callnarration here. I don't get it. There is nothing in my code that is stripping the \n? input name=DPRnarration type=text hidden form=DPRform value=?php echo stripslashes($_POST[DPRnarration]);? Do I need to put it in another textarea and declare it hidden? Let me understand this logic. You have a form that gathers some text from a field and then you submit that form to a script that wants to put it back out in a hidden field on a new form? Is that it in a nutshell? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] stripped \n
On Wed, Feb 20, 2013 at 7:16 PM, John Taylor-Johnston john.taylor-johns...@cegepsherbrooke.qc.ca wrote: Hi, I have a textarea when submitted creates a new form with the textarea data in a hidden field: input name=DPRnarration type=text hidden form=DPRform value=Enter call narration here. But when this new form gets resubmitted, the \n get stripped? input name=DPRnarration type=text hidden form=DPRform value=Enter callnarration here. I don't get it. There is nothing in my code that is stripping the \n? input name=DPRnarration type=text hidden form=DPRform value=?php echo stripslashes($_POST[**DPRnarration]);? Do I need to put it in another textarea and declare it hidden? An input with type=text is used for single lines, so yes, newlines get stripped. Either use a textarea with style=display: none, or store the data in a session instead. - Matijn
Re: [PHP] stripped \n
On Wed, Feb 20, 2013 at 1:32 PM, Matijn Woudt tijn...@gmail.com wrote: An input with type=text is used for single lines, so yes, newlines get stripped. Either use a textarea with style=display: none, or store the data in a session instead. Or at least input type=hidden/. -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] stripped \n
On 2/20/2013 1:32 PM, Matijn Woudt wrote: On Wed, Feb 20, 2013 at 7:16 PM, John Taylor-Johnston john.taylor-johns...@cegepsherbrooke.qc.ca wrote: Hi, I have a textarea when submitted creates a new form with the textarea data in a hidden field: input name=DPRnarration type=text hidden form=DPRform value=Enter call narration here. But when this new form gets resubmitted, the \n get stripped? input name=DPRnarration type=text hidden form=DPRform value=Enter callnarration here. I don't get it. There is nothing in my code that is stripping the \n? input name=DPRnarration type=text hidden form=DPRform value=?php echo stripslashes($_POST[**DPRnarration]);? Do I need to put it in another textarea and declare it hidden? An input with type=text is used for single lines, so yes, newlines get stripped. Either use a textarea with style=display: none, or store the data in a session instead. - Matijn Actually - an input type=text may be intended for single lines, but my test shows that it does not drop the \ all by itself. And actually, the poster's question is very difficult to understand, simply because I do believe he doesn't know anything about html or php. Probably building something from examples he has seen. 1 - he doesn't show a textarea tag in his examples 2 - his sample of his code is such a small fragment we can't tell WHAT he is doing. Most likely the problem is his use of stripslashes in that last code line he provided. I wonder if he knows what that does? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] stripped \n
On Wed, 2013-02-20 at 13:47 -0500, Jim Giner wrote: On 2/20/2013 1:32 PM, Matijn Woudt wrote: On Wed, Feb 20, 2013 at 7:16 PM, John Taylor-Johnston john.taylor-johns...@cegepsherbrooke.qc.ca wrote: Hi, I have a textarea when submitted creates a new form with the textarea data in a hidden field: input name=DPRnarration type=text hidden form=DPRform value=Enter call narration here. But when this new form gets resubmitted, the \n get stripped? input name=DPRnarration type=text hidden form=DPRform value=Enter callnarration here. I don't get it. There is nothing in my code that is stripping the \n? input name=DPRnarration type=text hidden form=DPRform value=?php echo stripslashes($_POST[**DPRnarration]);? Do I need to put it in another textarea and declare it hidden? An input with type=text is used for single lines, so yes, newlines get stripped. Either use a textarea with style=display: none, or store the data in a session instead. - Matijn Actually - an input type=text may be intended for single lines, but my test shows that it does not drop the \ all by itself. And actually, the poster's question is very difficult to understand, simply because I do believe he doesn't know anything about html or php. Probably building something from examples he has seen. 1 - he doesn't show a textarea tag in his examples 2 - his sample of his code is such a small fragment we can't tell WHAT he is doing. Most likely the problem is his use of stripslashes in that last code line he provided. I wonder if he knows what that does? Also, with the example: input name=DPRnarration type=text hidden form=DPRform value=Enter call narration here. There is no hidden attribute for input elements, and no form attribute either. If there's a need to stuff elements with extra attributes then it's best to use data- attributes. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] phpinfo()
Design in Motion Webdesign wrote: John Taylor-Johnston john.taylor-johns...@cegepsherbrooke.qc.ca wrote: I cannot find button2 in phpinfo() when I click it. I was hoping to find a $_POST[button2] value. What am I doing wrong? input type=button name=button2 id=button2 value=Print Mode onclick=formSubmit() I really wanted to use a button to pass a different condition than a input type=submit Use a different value or name on the input type=submit/ button. Don't use JavaScript to trigger the form like that. Its not necessary and will bite you in the ass if ypu get a visitor who browses without JavaScript, which can include security aware users, blind users, etc Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Try $_POST['button2'] Best regards. Steven $_POST['button2'] does not exist. I'm using radio to get aorund it for now. A button would have been cleaner. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] phpinfo()
On Wed, 2013-02-20 at 14:23 -0500, John Taylor-Johnston wrote: Design in Motion Webdesign wrote: John Taylor-Johnston john.taylor-johns...@cegepsherbrooke.qc.ca wrote: I cannot find button2 in phpinfo() when I click it. I was hoping to find a $_POST[button2] value. What am I doing wrong? input type=button name=button2 id=button2 value=Print Mode onclick=formSubmit() I really wanted to use a button to pass a different condition than a input type=submit Use a different value or name on the input type=submit/ button. Don't use JavaScript to trigger the form like that. Its not necessary and will bite you in the ass if ypu get a visitor who browses without JavaScript, which can include security aware users, blind users, etc Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Try $_POST['button2'] Best regards. Steven $_POST['button2'] does not exist. I'm using radio to get aorund it for now. A button would have been cleaner. input type=submit name=button2 value=button/ Not sure what you have against submit buttons, because this will do what you want and you don't need to be doing whatever it is you're doing with radio buttons? Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] phpinfo()
On 20 Feb 2013, at 19:23, John Taylor-Johnston john.taylor-johns...@cegepsherbrooke.qc.ca wrote: Design in Motion Webdesign wrote: John Taylor-Johnston john.taylor-johns...@cegepsherbrooke.qc.ca wrote: I cannot find button2 in phpinfo() when I click it. I was hoping to find a $_POST[button2] value. What am I doing wrong? input type=button name=button2 id=button2 value=Print Mode onclick=formSubmit() I really wanted to use a button to pass a different condition than a input type=submit Use a different value or name on the input type=submit/ button. Don't use JavaScript to trigger the form like that. Its not necessary and will bite you in the ass if ypu get a visitor who browses without JavaScript, which can include security aware users, blind users, etc Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Try $_POST['button2'] Best regards. Steven $_POST['button2'] does not exist. I'm using radio to get aorund it for now. A button would have been cleaner. You were given the answer, did you not try it? Starting with the code in your original post: 1) Change the type to submit. 2) Remove the onclick. 3) Job done! -Stuart -- Sent from my leaf blower -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] stripped \n
On 02/20/2013 10:16 AM, John Taylor-Johnston wrote: Hi, I have a textarea when submitted creates a new form with the textarea data in a hidden field: input name=DPRnarration type=text hidden form=DPRform value=Enter call narration here. But when this new form gets resubmitted, the \n get stripped? input name=DPRnarration type=text hidden form=DPRform value=Enter callnarration here. I don't get it. There is nothing in my code that is stripping the \n? input name=DPRnarration type=text hidden form=DPRform value=?php echo stripslashes($_POST[DPRnarration]);? Do I need to put it in another textarea and declare it hidden? Here is a quote: If the element is mutable, its value should be editable by the user. User agents must not allow users to insert LF (U+000A) or CR (U+000D) characters into the element's value. I found it on this page: http://www.w3.org/TR/html5/forms.html#text-%28type=text%29-state-and-search-state-%28type=search%29 Does that explain why your example doesn't work? -- Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] phpinfo()
On Feb 20, 2013, at 2:31 PM, Stuart Dallas stu...@3ft9.com wrote: You were given the answer, did you not try it? Starting with the code in your original post: 1) Change the type to submit. 2) Remove the onclick. 3) Job done! -Stuart Sometimes you just can't help. Sent from my leaf blower :-) Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] phpinfo()
On Wed, Feb 20, 2013 at 1:31 PM, Stuart Dallas stu...@3ft9.com wrote: -Stuart -- Sent from my leaf blower -- Did you get the 4G model, or is this just the WiFi version? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] parsing select multiple=multiple
On Tue, Feb 19, 2013 at 1:02 PM, John Taylor-Johnston john.taylor-johns...@cegepsherbrooke.qc.ca wrote: tamouse mailing lists wrote: I hate arrays. :D Here's a small snippet showing how it works, I hope: foreach ($DPRpriority as $item = $value) { echo li .$item.: .$value['name']. selected: .$value['selected']. /li\n; } Question 1: when did we have to add [] to a input name to turn it into an array? input type=checkbox name=DPRlocationdetails[] value=Unknown According to phpinfo() it still comes out as $_POST['DPRlocationdetails'] without []. Are the [] necessary? [] are necessary when you want to return multiple values for a form field, or collection of form fields such as checkbox. AFAIK, this has always been the case with PHP. See https://gist.github.com/tamouse/5002728 -- Question 2: I was looking at some code in the Manual, where someone used isset and is_array. How necessary is if(isset($_POST['DPRlocationdetails'])) and then to use: if(is_array($_POST['DPRlocationdetails'])) That seems like over kill? It's more defensive, in the case where someone may be by-passing your form to send things in. -- Question 3: My code works, perfectly. Then there must be no questions. :) In this case, I decided to attack some check-boxes first. The resulting function will work for select multiple too.. Does anyone see me doing something wrong in my code below? My questions are: Is this the only way to pass Unknown, Family Home or Apartment into the function? Is this correct? if ($_POST['DPRlocationdetails'] == Unknown) Somebody once told me I had to do it this way? if (Unknown == $_POST['DPRlocationdetails']) In this scenario, these are equivalent. There is no preference of one over the other. I *have* heard claims that something like this is preferrable, though: if (FALSE === $variable) But I think that may have been due to some misunderstanding of precedences in the following sort of scenario: if (FALSE === ($result = some_function()) where if done this way: if ($result = some_function() === FALSE) was giving them bad results. John snip--- form action=foo.php id=DPRform method=postinput value=Update type=submit input type=checkbox name=DPRlocationdetails[] value=Unknown ?php filter_value($_POST['DPRlocationdetails'],Unknown); ? Unknown input type=checkbox name=DPRlocationdetails[] value=Family Home ?php filter_value($_POST['DPRlocationdetails'],Family Home); ? Family Home input type=checkbox name=DPRlocationdetails[] value=Apartment ?php filter_value($_POST['DPRlocationdetails'],Apartment); ? Apartment /form ?php function filter_value($tofilter,$tofind) { foreach($tofilter as $value){ if ($value == $tofind) echo checked; } } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php