php-general Digest 21 Feb 2013 06:17:15 -0000 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
----------------------------------------------------------------------
--- Begin Message ---
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 ---
--- Begin Message ---
> 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 ---
--- Begin Message ---
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 ---
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
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.
--- End Message ---
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
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?
--- End Message ---
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
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.
--- End Message ---
--- Begin Message ---
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?
--- End Message ---
--- Begin Message ---
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?
--- End Message ---
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
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/
--- End Message ---
--- Begin Message ---
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?
--- End Message ---
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
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/
--- End Message ---