Hi,
I am trying to check for the existance of a certain value (ie $login, taken from my 
first PHP page: member.php) in the "first" column of my database "mydb.
The value of "$login" is passed from member.php.

My data base "mydb" contains 1 table called emplyoees which was created as follows:
CREATE TABLE employees (  id tinyint(4) DEFAULT '0' NOT NULL AUTO_INCREMENT,  first 
varchar(20),  last varchar(20),  address varchar(255),  position varchar(50),  PRIMARY 
KEY (id),  UNIQUE id (id));
INSERT INTO employees VALUES (1,'Bob','Smith','128 Here St, Cityname','Marketing 
Manager');

My code is as follows:
member.php:

<?php  
// send wml headers 
header("Content-type: text/vnd.wap.wml");  
echo "<?xml version=\"1.0\"?>";  
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\""  
   . " \"http://www.wapforum.org/DTD/wml_1.1.xml\">"; 
?>
<wml>
<template>
 <do type='prev' label='Back'>
  <prev/>
 </do>
        <do type='accept' label='OK'>
 <go href="http://localhost/WAP/member2.php?login=$(login)"/> 
 </do>
</template>
 

<card  id='registered' title='Members'> 
<p>
  Please enter your First Name: <input name='login' type ='text'/>
</p>
</card>
</wml>

member2.php:

<?php  
// send wml headers 
header("Content-type: text/vnd.wap.wml");  
echo "<?xml version=\"1.0\"?>";  
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\""  
   . " \"http://www.wapforum.org/DTD/wml_1.1.xml\">"; 
?>
<wml>

<card id="membercheck" title="Member Check">
<p>
<?php
    $db = mysql_connect("localhost", "root");
    mysql_select_db("mydb",$db);
    $sql = "SELECT * FROM employees where first = '$login'";
    $result = mysql_db_query ("mydb", $sql);
    $myrow = mysql_fetch_array($result);
    printf($myrow["first"]);
    printf($myrow["last"]);
    printf($myrow["address"]);
    printf($myrow["position"]);
?>
</p>
</card>
</wml>

When I enter a valid "first" name ie Bob it works fine and outputs everything to the 
screen.
If I enter a name that does not exist in the database it just puts up and empty WML 
page.
Is there a way of checking for the existance of $login in the "first" column of my 
database and if so doing somethin for example printing out "Success" other wise, if it 
is not a member printing out something different?
I have tried saying 
if ($result = 'Resource id #2){
print (Success);
}else{
print (Fail);
}
because if i echo out $login that is the value i get but it doesn't work.
If anyone has any alternative suggestions as an approach to this problem then I am all 
ears!!

Thank you,

Kevin. 


Reply via email to