Jump to content

AND/OR operators


NHStars

Recommended Posts

I'm working on a code to validate some data through a post form...my problem is that I'm trying to figure out if both of my variables are empty or not.

it's basically something like this

[color=red]$ef = $_POST['f'];
$es = $_POST['s'];

if (!$ef [color=green]AND[/color] !$es) {

code here blah blah

}
[/color]

Being that I come from a background of Visual Basic programming, I figured I'd try this. Now I can't seem to find out what the PHP equivalent is. Same with OR in place of AND. Anything you guys can tell me is appreciated. Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/30584-andor-operators/
Share on other sites

The problem with checking to see if the field is empty with the empty() function is that if the field contains the single character "0" the function emtpy() will return "true". I use the following to see if the field is emty:
[code]<?php
if (strlen(trim(stripslashes($_POST['fld']))) == 0) echo 'The field is emtpy';
?>[/code]

Ken
Link to comment
https://forums.phpfreaks.com/topic/30584-andor-operators/#findComment-140882
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.