Forum Moderators: coopster

Message Too Old, No Replies

PHP check two MySQL tables

         

andrewheiss

6:54 pm on Jan 11, 2008 (gmt 0)

10+ Year Member



I'm trying to make a psuedo login page where a user can input their first name, last name, and e-mail address to verify if they are a member of a professional academic association. There are two different associations I'm checking against; both lists are in different tables. I'm trying to have PHP check to see if the user is either a member of one or the other, but can't get it working right. It works fine if I only check one or the other

Here's what I have:


<?php
if (isset($_POST['submit'])) {
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];

require_once('../../connect.php');
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

$checkula = mysql_query("SELECT * FROM members_ula WHERE firstname = '$firstname' AND lastname = '$lastname' AND email = '$email'")or die(mysql_error());
$checkula1 = mysql_num_rows($checkula);

$checkmpla = mysql_query("SELECT * FROM members_mpla WHERE firstname = '$firstname' AND lastname = '$lastname' AND email = '$email'")or die(mysql_error());
$checkmpla1 = mysql_num_rows($checkmpla);

if ($checkula1 == 0 ¦¦ $checkmpla1 ==0) {
$member = "no";
} else {
$member = "yes";
}
} else {
$member = "no";
}
?>

It's probably just a problem in the logic of the if/then programming. I'd appreciate any help I can get.

Thanks!

dreamcatcher

7:00 pm on Jan 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Shouldn`t this line:

if ($checkula1 == 0 ¦¦ $checkmpla1 ==0) {

Be this:

if ($checkula1 == 0 && $checkmpla1 ==0) {

dc

andrewheiss

7:21 pm on Jan 11, 2008 (gmt 0)

10+ Year Member



Perfect! That fixed it. I knew there had to be some operator.

I had actually clunkily fixed it after posting the original question by sticking the checkmpla thing inside the checkula part. It worked, but was really ugly and unwieldy.

I changed it to this. Whew!