Search the Community
Showing results for tags 'successful'.
-
Not sure why I can't get this been trying to figure it out all evening :/ The included smconfig.php contains my database password. Any ideas, I know it's gotta be easy, I must be missing something. PDO connect.php: <?php session_start(); include 'smconfig.php'; $db_host = "127.0.0.1"; $db_username = "root"; $db_pass = "$dbpass"; $db_name = "golden_wand"; // PDO CONNECT $db = new PDO('mysql:host='.$db_host.';dbname='.$db_name,$db_username,$db_pass); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); ?> http://www.golden-wand.com/members/tester.php <?php include "../Scripts/connect.php"; $email = "test@gmail.com"; $stmt1 = $db->prepare("SELECT id, activated, username, email, password, token FROM members WHERE email=:email LIMIT 1"); $stmt1->bindParam(':email',$email,PDO::PARAM_STR); $stmt1->execute(); $count = $stmt1->rowCount(); if($count > 0){ while($row = $stmt1->fetch(PDO::FETCH_ASSOC)){ $uid = $row['id']; $username = $row['username']; $email = $row['email']; $hash = $row['password']; $activated = $row['activated']; $token = $row['token']; } } echo "Before: <br>"; echo 'UID = '.$uid; echo '<br>Token = '.$token; echo '<br>Activated = '.$activated; echo '<br>Hash = '.$hash; $activated="1"; $token = "md5($hash)"; try{ $db->beginTransaction(); $updateSQL = $db->prepare("UPDATE members SET activated=':activated' WHERE id=':uid' LIMIT 1"); $updateSQL->bindParam(':activated',$activated,PDO::PARAM_STR); $updateSQL->bindParam(':uid',$uid,PDO::PARAM_INT); $updateSQL->execute(); $db->commit(); echo "<br><br><br><br>Update Successful<br><br><br><br>"; } catch(PDOException $e){ $db->rollback(); echo "<br><br><br><br>Update Failed<br><br><br><br>"; } $stmt2 = $db->prepare("SELECT id, activated, username, email, password, token FROM members WHERE email=:email LIMIT 1"); $stmt2->bindParam(':email',$email,PDO::PARAM_STR); $stmt2->execute(); $count = $stmt2->rowCount(); if($count > 0){ while($row = $stmt2->fetch(PDO::FETCH_ASSOC)){ $uid = $row['id']; $username = $row['username']; $email = $row['email']; $hash = $row['password']; $activated = $row['activated']; $token = $row['token']; } } echo "After: <br>"; echo 'UID = '.$uid; echo '<br>Token = '.$token; echo '<br>Activated = '.$activated; echo '<br>Hash = '.$hash; ?> I own this site: http://www.golden-wand.com/phpfreaks.txt