PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
someguyhere
Forum Contributor
Posts: 181 Joined: Sun Jul 27, 2008 3:24 pm
Post
by someguyhere » Tue Sep 10, 2013 9:16 am
Can anyone tell me doing wrong here?
Code: Select all
if ( isset ( $_POST['length'] && $_POST['width'] && $_POST['height'] ) ) {
Celauran
Moderator
Posts: 6427 Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada
Post
by Celauran » Tue Sep 10, 2013 9:49 am
priyankagound
Forum Commoner
Posts: 27 Joined: Thu Sep 19, 2013 2:53 am
Post
by priyankagound » Fri Sep 20, 2013 5:09 am
If multiple parameters are supplied then isset() will return TRUE only if all of the parameters are set.
if (isset($length, $width, $height)) {
/.....
}
someguyhere
Forum Contributor
Posts: 181 Joined: Sun Jul 27, 2008 3:24 pm
Post
by someguyhere » Fri Sep 20, 2013 2:44 pm
Right; I need them all to be set. I will try if (isset($length, $width, $height)) {
Thanks guys!
requinix
Spammer :|
Posts: 6617 Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA
Post
by requinix » Fri Sep 20, 2013 2:47 pm
As long as you're not doing
Code: Select all
$length = $_POST['length'];
$width = $_POST['width'];
$height = $_POST['height'];
if (isset($length, $width, $height)) {
because that won't help with the "undefined offset" warnings should those things not be present.
someguyhere
Forum Contributor
Posts: 181 Joined: Sun Jul 27, 2008 3:24 pm
Post
by someguyhere » Fri Sep 20, 2013 3:23 pm
I am. Should I set them in an array instead?
requinix
Spammer :|
Posts: 6617 Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA
Post
by requinix » Fri Sep 20, 2013 3:44 pm
No arrays either. Deal with $_POST directly like you were doing before: take your original code and put commas in for the &&s.
Code: Select all
if ( isset ( $_POST['length'], $_POST['width'], $_POST['height'] ) ) {