Antonio King
asked on
Hopw do i return a true or false result from a function
I have created this function...
function ActivateAccount(){
global $database;
$pass = stripslashes($_GET['hash'] );
$user = base64_decode($_GET['stamp ']);
$q = "UPDATE ".TBL_USERS." SET status = '1' WHERE (password = $pass) AND (username = '$user')";
$database->query($q);
}
Would like to know, how to pass some kind of string or something that i can use later on in the document...
like...
<? if($status == 0){
?>
account not activated
<? }else{ ?>
account activate!
<? } ?>
How do I do this?
function ActivateAccount(){
global $database;
$pass = stripslashes($_GET['hash']
$user = base64_decode($_GET['stamp
$q = "UPDATE ".TBL_USERS." SET status = '1' WHERE (password = $pass) AND (username = '$user')";
$database->query($q);
}
Would like to know, how to pass some kind of string or something that i can use later on in the document...
like...
<? if($status == 0){
?>
account not activated
<? }else{ ?>
account activate!
<? } ?>
How do I do this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
function ActivateAccount(){
global $database;
$pass = stripslashes($_GET['hash'] );
$user = base64_decode($_GET['stamp ']);
$q = "UPDATE ".TBL_USERS." SET status = '1' WHERE (password = $pass) AND (username = '$user')";
$database->query($q);
if($database->affected_row s){
return "account activate!";
}else{
return "account not activated";
}
}
global $database;
$pass = stripslashes($_GET['hash']
$user = base64_decode($_GET['stamp
$q = "UPDATE ".TBL_USERS." SET status = '1' WHERE (password = $pass) AND (username = '$user')";
$database->query($q);
if($database->affected_row
return "account activate!";
}else{
return "account not activated";
}
}
ASKER
ok ... still not working as i'd like.
<? include("include/session.p hp");
function ActivateAccount(){
global $database;
$pass = stripslashes($_GET['hash'] );
$user = base64_decode($_GET['stamp ']);
$q = "UPDATE ".TBL_USERS." SET status = '1' WHERE (password = $pass) AND (username = '$user')";
$database->query($q);
if($database->affected_row s){
return true;
}else{
return false;
}
}
?>
<?
$activatedresult = ActivateAccount();
if($activatedresult = true){
echo "congratulations";
}else{
echo "boo hoo ";
}
IT always returns congratulations... even when the sql database is not updated.
<? include("include/session.p
function ActivateAccount(){
global $database;
$pass = stripslashes($_GET['hash']
$user = base64_decode($_GET['stamp
$q = "UPDATE ".TBL_USERS." SET status = '1' WHERE (password = $pass) AND (username = '$user')";
$database->query($q);
if($database->affected_row
return true;
}else{
return false;
}
}
?>
<?
$activatedresult = ActivateAccount();
if($activatedresult = true){
echo "congratulations";
}else{
echo "boo hoo ";
}
IT always returns congratulations... even when the sql database is not updated.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok, stil not working... "boo hoo" is displayed even though the sql database has been updated.
put quotes around $pass in your query
$q = "UPDATE ".TBL_USERS." SET status = '1' WHERE (password = '$pass') AND (username = '$user')";
$q = "UPDATE ".TBL_USERS." SET status = '1' WHERE (password = '$pass') AND (username = '$user')";
ASKER
the query doesn't work with quotes around $pass
you get an error ?
try the following lines
$q = "UPDATE ".TBL_USERS." SET status = '1' WHERE (`password` = '$pass') AND (username = '$user')";
$database->query($q) or die($database->error);
try the following lines
$q = "UPDATE ".TBL_USERS." SET status = '1' WHERE (`password` = '$pass') AND (username = '$user')";
$database->query($q) or die($database->error);
ASKER
used parts of all your solutions. Thanks for the help
$q = "UPDATE TBL_USERS SET status = '1' WHERE (password = '$pass') AND (username = '$user')";
if ($status == 0)
return "account not activated";
else
return "account activated";