Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP Activating account with UPDATE SQL
    primarykey
    data
    text
    <p>OK I have this code to send an email account verification link </p> <pre><code> $verifyemail = $clean['email']; $to = $verifyemail; $subject = 'Virtual Pierz Close | Verify Your Account'; $message = "Thanks for registering with VPC, on clicking the verification link below, your account will be confirmed, you can then go ahead buy Virtual Properties, donating £5 each time to the worthwhile charity. http://www.cambrianvacation.co.uk/vpc/registered.php? email='$verifyemail'&amp;hash='$hash1' "; $headers = 'From:noreply@cambrianvacation.co.uk'; // Set from headers mail($to, $subject, $message, $headers); </code></pre> <p>And then I have this code, that is trying to activate the account by setting active = 1 in the database, which will then be part of the access control logic at login, without active = 1, there is no login, amongst other protection</p> <pre><code> if(isset($_GET['email']) &amp;&amp; !empty($_GET['email']) AND isset($_GET['hash']) &amp;&amp; !empty($_GET['hash'])){ // Verify data $accountemail = $_GET['email']; $accounthash = $_GET['hash']; } $accountActive = 1; $notactive = 0; $username = ''; $password2 = ''; $username = 'xxxxxxx'; $password2 = 'xxxxxxx'; $db1 = new PDO('mysql:host=localhost;dbname=xxxxxxxxxxxxx', $username, $password2, array(PDO::MYSQL_ATTR_INIT_COMMAND =&gt; "SET NAMES utf8")); $db1-&gt;setAttribute(PDO::ATTR_EMULATE_PREPARES, false); $db1-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); try{ $search = $db1-&gt;prepare("SELECT email, hash, active FROM users WHERE email = :email AND hash= :hash AND active = :active"); $search-&gt;bindParam(':email', $accountemail); $search-&gt;bindParam(':hash', $accounthash); $search-&gt;bindParam(':active', $notactive); $search-&gt;execute(); $colcount = $search-&gt;columnCount(); }catch(PDOException $e) { $e-&gt;getMessage(); } print_r($colcount); if($colcount === 3){ //try{ $update = $db1-&gt;prepare("UPDATE users SET active=:active WHERE email=:email AND hash=:hash AND active = :active"); $update-&gt;bindParam(':active', $accountActive); $update-&gt;bindParam(':email', $accountemail); $update-&gt;bindParam(':hash', $accounthash); $update-&gt;bindParam(':active', $notactive); $update-&gt;execute(); //}catch(PDOException $e) { // $e-&gt;getMessage(); //} </code></pre> <p>However I cannot get the active column to update.</p> <p>I've also thought about using the GET['email'] could be subject to semantic url attacks, however the logic won't activate the account without the matching hash, which is randomly generated with crypt()......... If anyone can see any security holes in the code, please tell me......... </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload