Link to home
Start Free TrialLog in
Avatar of cntmedia
cntmedia

asked on

true false statement mysql php

Looking for a quick  example on how make a php to mysql (true / false) compare.

This would be using a sign up form:

So all the basic stuff I have down (login/sql/query/etc..)



I am guessing....example code ;)
 
// old or new user example //
 
function oldOrNew (signupID)
 
{
    login into db;
    login into myTable ;
	//compare the id against the table//
 
	if(userid on myTable == signupID & oldPassword on myTable == newPassword)
	{
		echo "you already have signed up...but you have uninstalled the application"
 
		echo "please fill out form about what we could have done to make it a better app, and thanks for coming back!"
 
	}   
 
	else
	{
		echo "thanks for signing up"
		doSomeFunction();
    }
 
 
 
 
}
 
// 11223 would be the example var ID to pass to the function //
 
oldOrNew(11223);

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I think the easiest way to find out if a user had already signed up would be to select the user's id out of the data table.  If there are no rows, you have not got a user with that id.

HTH, ~Ray
if (!$r = mysql_query("SELECT uid FROM users WHERE ukey = 11223 LIMIT 1")) { die(mysql_error()); }
 
// IF MYSQL NUM ROWS IS ZERO, IT IS THE SAME AS FALSE; IF ONE IT IS TRUE
if (mysql_num_rows($r)) {
   echo "Already signed up";
} else {
   echo "Not signed up yet";
}

Open in new window