Problem: I can't get the email value after inserting into the database.

EDITED:

Fixed:
my problem were `$to = $_POST['$email'];` gave wrong value to it. it should be `$to = $_POST['email'];`. 
Problem was because i had $ for giving value.

This is how I create my activation code:

```
$activation = sha1(uniqid(rand(), true));

```

This is how I declare my database insert query:

```
$query = "INSERT INTO users (activation, email) VALUES (:activation, :email)"; 

```

Here I populate the parameters for my insert query:

```
$query_params = array(
  ':activation' => $activation,
  ':email' => $_POST['email']
); 

```

...and here's how I add the data to my database by executing the query and send an email:

```
    try 
    { 
        // Execute the query to create the user 
        $stmt = $db->prepare($query); 
        $stmt->execute($query_params);

        if ($stmt->rowCount() > 0) { //If the Insert Query_params was successfull.
            echo 'even gets to  here.';

            // Send the email:
            $to = $_POST['email'];
            $subject = 'Registeerimis kinnitus';
            $from = 'From: mymail@gmail.com';
            $WEBSITE_URL = "http://mysite.com";
            $message = " Kasutaja aktiveerimiseks, palun vajutage aadressile:\n\n";
            $message .= $WEBSITE_URL . "/activate.php?email=" . urlencode($to) . "&key=".$activation;
            mail($to, $subject, $message);
        }
    } 
    catch(PDOException $ex) 
    { 
        // Note: On a production website, you should not output $ex->getMessage(). 
        // It may provide an attacker with helpful information about your code.  
        die("Failed to run query: " . $ex->getMessage()); 
    }

```

The insert to the database works. 

Thanks in advance for any help.