0

I am adding an email validation step to my user registration. I cannot seem to get access to the arguments that are being passed in the emailed link;

link: activation.php?email=someone@somewhere.com&key=5614c46be05a95f55f2231d8dea41418d17b197a

Here is the page code;

class page_activation extends Page {
    function init(){
        parent::init();

    if($this->api->auth->isLoggedIn())$this->api->redirect('index');

    $loginAccount = $_GET['email'];
    $activationKey = $_GET['key'];

    $this->add('H1')->set('Activated');
    $this->add('H3')->set('Account: '.$loginAccount);
    $this->add('H3')->set('Key: '.$_GET['key']);
}
Micheal
  • 105
  • 7
  • Did you try debugging it? Is see, that there are some curly braces missing... Probalby the cause of the error. Check your `if` statement! – Mārtiņš Briedis Jul 17 '12 at 02:39
  • The formatting made it look like the {} were missing for the if statement. It outputs "Activated, Account, and Key" but without the contents of the passed arguments. I have updated the original post. – Micheal Jul 17 '12 at 03:52
  • It seems that I cannot answer my question. But the answer won't fit. You can tell I am new to this... – Micheal Jul 17 '12 at 06:03
  • Did you really mean this? `if($this->api->auth->isLoggedIn())$this->api->redirect('index');` Always redirect to index, if user IS logged in? – Mārtiņš Briedis Jul 17 '12 at 11:05

2 Answers2

0
var_dump($_GET);
  • check network tab in inspector to make sure get params are actually passed.
  • check mod rewrite rules
jancha
  • 4,916
  • 1
  • 24
  • 39
0

I have found a solution in case it might help someone. It seems you can access the $_SERVER vars but the $_GET vars are lost by the time you get to the page. Here is some code that I used to accesses the passed vars from the email link;

class page_activation extends Page {
function init(){
    parent::init();

    if($this->api->auth->isLoggedIn())$this->api->redirect('index');

    $data = parse_url($_SERVER['REQUEST_URI'], PHP_URL_QUERY);
    $queryParts = split('[;&]', $data);

    $params = array(); 
    foreach ($queryParts as $param) { 
        $item = explode('=', $param); 
        $params[$item[0]] = $item[1]; 
    }

    $loginAccount = $params['email'];
    $activationKey =  $params['key'];

    $this->add('H1')->set('Activated');
    $this->add('H3')->set('Account: '.$loginAccount);
    $this->add('H3')->set('Key: '.$activationKey);


}

}

Micheal
  • 105
  • 7