Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

if/else after search.

Status
Not open for further replies.

rahulpatel

Programmer
Jan 20, 2007
33
AU
I have a club site that has a membership system. I would like guests to search for usernames to see if they are registered.(Only to say username is registered or not, no other details) It uses ajax (hence why this post is in this thread) to say whether or not username is regsitered. It all works, pulling the correct information but I want it to say 'username registered' or 'not registered'. Here's where I'm coming unstuck...
Code:
<?php
    
    $sID = $_GET["id"];
    
    $sInfo = "";
    
    $sQuery = "Select username from members where username =".$sID;
              
    $oLink = mysql_connect($sDBServer,$sDBUsername,$sDBPassword);
    @mysql_select_db($sDBName) or $sInfo = "Unable to open database";
        
    if($sID == '') {
	$sInfo = "Member registered";
        } else {
            $sInfo = "Member $sID not registered.";
        }
    
    mysql_close($oLink);

?>

Hope you guys can assist me.
 
had a bit of a play and got it working.

Code:
if($sInfo == '') {
if($oResult = mysql_query($sQuery) and ysql_num_rows($oResult) > 0) {
$aValues = ysql_fetch_array($oResult,MYSQL_ASSOC);

    $sInfo = "Member registered";
        } else {
            $sInfo = "Member not registered.";
        }

and it works. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top