Page 1 of 1

returning a $var in email activation tut

Posted: Wed Nov 30, 2011 1:31 am
by shaunthomson
Hi

I've been customising the email registration php, and have come a ways with it. I've added a few more processes to the activation, including setting up a user directory. And it seems to be working.

Now I'd like to return to activate.php a true value for when the dir set up (which is the last process) is successful.

I can't seem to get a var returned though.

So activate.php has:
if(isset($_GET['aid'])) {
		
		activate_account($_GET['aid']);		
		
	}
Then in user.inc.php...
function activate_account($aid) {}   
activates, then
make_user_dir($user_dir); 
runs
function make_user_dir($user_dir) {}
Everything works fine up to this point. Then, in make_user_dir, I put
$var = "successful";
return $var;
but I can't figure out how to get activate.php to echo $var

Is the fact that I've jumped from one function to another affecting the return?

Thanks guys

Shaun

Re: returning a $var in email activation tut

Posted: Wed Nov 30, 2011 5:04 pm
by jacek
Hmm, it would be possible using the session, but another method that you could consider using would be to have activate check to see if the last step has happened. The last step is creating a folder, if you know the path to that folder you could do
if (is_dir("user_folders/{$_SESSION['username']}")){
    // user has activated because their folder exists and that is the last step of activation.
}
You could even wrap it in a function
function is_user_activated($username){
    return is_dir("user_dirs/{$username}");
}