chris_s_22 Posted January 5, 2009 Share Posted January 5, 2009 im at the point of creating a email confirmation that when a person recieves the email and clicks on the link it directs them to conformationcheck.php <? include('config.php'); // Passkey that got from link $passkey=$_GET['passkey']; // Retrieve data from table where row that match this passkey $sql1="SELECT * FROM user WHERE confirm_code ='$passkey'"; $result1=mysql_query($sql1); // If successfully queried if($result1){ // Count how many row has this passkey $count=mysql_num_rows($result1); // if found this passkey in our database if($count==1){ ???? // Insert data $sql2="INSERT INTO user(registered)VALUES('$registered')"; $result2=mysql_query($sql2); } // if not found passkey, display message "Wrong Confirmation code" else { header('Location: http://www.pinkangel4u.com/truthdare/conformation.php'); } // if successfully inserted if($result2){ header('Location: http://www.pinkangel4u.com/truthdare/loginregister.php'); // Delete information in the confirmcode feild $sql3="DELETE FROM user WHERE confirm_code = '$passkey'"; $result3=mysql_query($sql3); } } ?> not sure want to add after if($count==1){ want i want this script to do firstly to get passkey from email then check it against my database, if found then insert "activated" into the registered feild in my database table. i then want it to only delete and clear the confirmcode feild in my database feild think at the moment if deletes the whole record or that person registered Quote Link to comment https://forums.phpfreaks.com/topic/139595-adding-a-email-verification-to-my-register-script/ Share on other sites More sharing options...
premiso Posted January 5, 2009 Share Posted January 5, 2009 You would want to run an UPDATE not an insert: // Insert data $sql2="UPDATE user SET registered = '1'"; $result2=mysql_query($sql2) Make sure the register column is an int and if it is 0 the user is not registered if it is 1 the user is valid and allowed. Quote Link to comment https://forums.phpfreaks.com/topic/139595-adding-a-email-verification-to-my-register-script/#findComment-730301 Share on other sites More sharing options...
GingerRobot Posted January 5, 2009 Share Posted January 5, 2009 As an aside, if you just want to ascertain whether or not the value exists in the database, it is far more efficient to perform a query that selects a count, rather than returning all rows and using the php mysql_num_rows() function. For example: $sql = "SELECT COUNT(*) FROM user WHERE confirm_code ='$passkey'"; $result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR); if(mysql_result($result,0) == 1){ //code found } Quote Link to comment https://forums.phpfreaks.com/topic/139595-adding-a-email-verification-to-my-register-script/#findComment-730326 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.