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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.