php email verification using secret key
<p>I've created a hash in confirm_email.php</p>

<pre><code>$email = "blah@blah.com";
$secret = "$#@%^&amp;$#$%^&amp;&amp;akeif"; //random characters
$hash = MD5($email . $secret);
$message = "https://localhost/mysite/register.php?email=" . $email . "&amp;hash=" . $hash;
</code></pre>

<p>and then sends the email. Upon clicking the link, I have the following code in register.php</p>

<pre><code>$secret = "$#@%^&amp;$#$%^&amp;&amp;akeif";

if(isset($_GET['hash']) and (MD5($_GET['email'] . $secret) == $_GET['hash'])) {
    //allow registration to continue processing

} else {
    //don't allow
}
</code></pre>

<p>Should I use sessions to store the secret (I guess I could create a user-specific secret if this were the case)? Or, is there a better way entirely to to create a hash for this approach? </p>

<p>Thanks in advance.</p>