chris_s_22 Posted January 17, 2009 Share Posted January 17, 2009 ok when my form is submitted it sucessfully enters the details into the database and sends the email and all seems to work fine function user_register($username, $password, $email) { // Get a salt using our function $salt = generate_salt(); // Now encrypt the password using that salt $encrypted = md5(md5($password).$salt); // Get a confirmation code $confirm_code=md5(uniqid(rand())); // Get the current date $regdate=date("Y-m-d") ; // checks if username in use $query = mysql_query("SELECT * FROM user WHERE username = '". $username ."'"); if (mysql_num_rows($query) > 0) { // Reshow the form with an error $login_error = 'username already taken'; include 'index.php'; exit; } // And lastly, store the information in the database $query = "insert into user (username, password, salt, email, confirmcode, regdate) values ('$username', '$encrypted', '$salt', '$email', '$confirm_code', '$regdate')"; $result=mysql_query($query) or die(mysql_error()); // if suceesfully inserted data into database, send confirmation link to email if($result) { // send e-mail to ... $to=$email; // Your subject $subject="Registration ... Your confirmation link here"; // Your messages and contents of the actual email $message="Your Comfirmation link \r\n"; $message.="Click on this link to activate your account \r\n"; $message.="http://www.pinkangel4u.com/Agency/loginreg/conformationcheck.php?passkey=$confirm_code&user_email=$user_email";// send email // send email $sentmail = mail($to,$subject,$message); } // if not found else { echo "Not found your email in our database"; } // if your email succesfully sent if($sentmail){ header('Location: http://www.pinkangel4u.com/Agency/loginreg/conformation.php'); } else { echo "Cannot send Confirmation link to your e-mail address"; } } in my database i have a feild named registered which is set to 0 as default. this below code is suposed to check data from the email to what was entered in the database in the above script. if sucessful it is suposed to change the default 0 in the registered feild to a 1 however when the link in the email is clicked it directs to index.php and echo the sucessful message, though when i check my database it hasnt changed the 0 to a 1 can someone help me figure out why <? include('init.php'); // Passkey that got from link $passkey=mysql_real_escape_string($_GET['passkey']); $user_email = mysql_real_escape_string($_GET['user_email']); $query = "UPDATE `user` SET `registered` = '1' WHERE `confirmcode` = '" . $passkey . "'"; if (!mysql_query($query)) { // handle failure echo "Incorrect code"; } else { // show login form with message $reg_checksuc = 'email verified please login'; include 'index.php'; exit; } ?> Quote Link to comment Share on other sites More sharing options...
chris_s_22 Posted January 17, 2009 Author Share Posted January 17, 2009 NO HELP? Quote Link to comment Share on other sites More sharing options...
revraz Posted January 17, 2009 Share Posted January 17, 2009 Are you connecting to the DB in init.php? echo $query and see what it returns. use mysql_error() after your query to check for errors. Your error checking is wrong. Checking if (!mysql_query($query)) to determine if the code is correct is not a accurate way. Your query won't produce an error if the confirmcode doesn't exist. Quote Link to comment Share on other sites More sharing options...
chris_s_22 Posted January 17, 2009 Author Share Posted January 17, 2009 made the changes after the query im now getting the error message Incorrect code im sure this has to do with what i am sending in the email can you see what? $message.="http://www.pinkangel4u.com/Agency/loginreg/conformationcheck.php?passkey=$confirm_code&user_email=$user_email";// send email Quote Link to comment Share on other sites More sharing options...
dawsba Posted January 17, 2009 Share Posted January 17, 2009 can you echo $_GET['passkey'] & mysql_real_escape_string($_GET['passkey']) Quote Link to comment Share on other sites More sharing options...
revraz Posted January 17, 2009 Share Posted January 17, 2009 When you echo the $query, post it so we can see it here. made the changes after the query im now getting the error message Incorrect code Quote Link to comment Share on other sites More sharing options...
chris_s_22 Posted January 17, 2009 Author Share Posted January 17, 2009 ok heres a update been messing about but have realised that when a email is sent the link looks something like this http://www.pinkangel4u.com/Agency/loginreg/conformationcheck.php?passkey=8d6c5d3db0bf69e9f33df79c73a28005&user_email= though no matter what is written after this http://www.pinkangel4u.com/Agency/loginreg/conformationcheck.php?passkey= if you was to put this into a browser and type something after, it directs to the index.php and displays email verified please login so its not checking the passkey Quote Link to comment Share on other sites More sharing options...
dawsba Posted January 17, 2009 Share Posted January 17, 2009 OK. but please post the get passkeys echos pre escape and after and if you can please echo the following code <?php $arr = array("_POST","_GET","_REQUEST"); foreach($arr as $k){foreach($$k as $k2=>$v){echo $k." -> ".$k2."--".$v."<BR>";} ?> Quote Link to comment Share on other sites More sharing options...
revraz Posted January 17, 2009 Share Posted January 17, 2009 Two things I would do: Echo $passkey Echo $_GET['passkey'] See if those two match. Next, why send the email with the URL if you don't use it? Quote Link to comment Share on other sites More sharing options...
chris_s_22 Posted January 17, 2009 Author Share Posted January 17, 2009 when i echo $passkey and echo the get returns 8d6c5d3db0bf69e9f33df79c73a28005 8d6c5d3db0bf69e9f33df79c73a28005 Quote Link to comment Share on other sites More sharing options...
revraz Posted January 17, 2009 Share Posted January 17, 2009 Does that match the confirmcode in the user table? Quote Link to comment Share on other sites More sharing options...
chris_s_22 Posted January 17, 2009 Author Share Posted January 17, 2009 im a blonde i really should be the problem was that when i created the table i only set the confirm code feild to INT 20 it need to be a larger number god at times im so stupid lol Quote Link to comment Share on other sites More sharing options...
revraz Posted January 18, 2009 Share Posted January 18, 2009 LoL, yep, it happens, glad you got it worked out. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.