oron Posted November 3, 2007 Share Posted November 3, 2007 Hey all, I was just wondering how exactly would I be able to create a validation for when someone signs up like, a email is sent and they have to click the link for their account to be activated. I have a rough Idea of what I would have to do... however I'm a bit unsure of how to get the random characters ect. Thanks, Nick Link to comment https://forums.phpfreaks.com/topic/75958-solved-validation-on-sign-up/ Share on other sites More sharing options...
cooldude832 Posted November 3, 2007 Share Posted November 3, 2007 one sec, i have a script I can show you, you will need to add 2 fields to your mysql database called Validate_key and validate the key is a varchar(32) and the validate is a bool or int(1) I found my script, so here is what you need <?php //generate a random string using your prefered method $string = rand_string_gen($length); //Id of the registered user $id = mysql_insert_id(); //Table Name $table = ""; //Table Primary Key $p_key = ""; $q = "Update `".$table."` Set V_key = '".$string."' where '".$p_key."' = '".$id."'"; $r = mysql_query($q) or die(mysql_error()); //Add to your mailer body $body .= "Please Verify your account by going to http://www.mysite.com/confirm.php?code='".$string."'&user='".$id."'"; ?> Then you will need to add a page similar to this that the link above goes to <?php <?php $code = $_GET['code']; $id = $_GET['id']; if(!empty($code) && is_numeric($id)){ //table name $table = ""; //Primary Key UserID $p_key = ""; $id = mysql_real_escape_string($id); $code = mysql_real_escape_string($code) ; $q = Select count(*) from `".$table."` Where '".$p_key."' = '".$id."' and V_key = '".$code."'"; $r = mysql_query($q) or die(mysql_error()); if(mysql_result($r,0)>0)){ $q ="Update `".$table."` Set V_set = '1' Where '".$p_key."' = '".$id."'"; $r = mysql_query($q) or die(mysql_error()); echo "Some message saying it worked"; } else{ echo "Some message saying code didn't match"; } } else{ echo "Invalid code"; } ?> That will confirm the code is right, and basically on your login script add something saying if the validate = 0 dont' login. I will let you figure out the resend page. Link to comment https://forums.phpfreaks.com/topic/75958-solved-validation-on-sign-up/#findComment-384478 Share on other sites More sharing options...
oron Posted November 3, 2007 Author Share Posted November 3, 2007 Alright, thanks a lot for the extremely quick reply Link to comment https://forums.phpfreaks.com/topic/75958-solved-validation-on-sign-up/#findComment-384480 Share on other sites More sharing options...
kratsg Posted November 3, 2007 Share Posted November 3, 2007 Just so you understand the concept. A validation key would be just a randomly made alphanumeric key (letters and numbers) and this is stored in the database. You would send a simple e-mail with a link that looks like this: http://www.yoursite.com/validate.php?id=######&key=13ufadjionhaf13490a Then, on validate.php, grab the user id (parse it to make sure that it IS numeric, just in case someone tries to hack, etc...). Use a query to grab the validation key from the database, match it to what the validation key is in the url... If they match, update validate to be 1 = true, 0 = false which is default. Then, if they try to visit the page again, you could just check to see if they were already validated, etc... -Give a man a fish, feed him for a day. Teach a man to fish, feed him for a lifetime.- Link to comment https://forums.phpfreaks.com/topic/75958-solved-validation-on-sign-up/#findComment-384483 Share on other sites More sharing options...
cooldude832 Posted November 3, 2007 Share Posted November 3, 2007 -Give a man a fish, feed him for a day. Teach a man to fish, feed him for a lifetime.- I agree with you, but i spent an hour trying to explain it to someone else a little bit ago so I figure I just give up an explianing for now Link to comment https://forums.phpfreaks.com/topic/75958-solved-validation-on-sign-up/#findComment-384485 Share on other sites More sharing options...
oron Posted November 3, 2007 Author Share Posted November 3, 2007 Haha, nice saying there, and thanks all for the help I understand it now Will try to make one tonight or perhaps in the morning. Link to comment https://forums.phpfreaks.com/topic/75958-solved-validation-on-sign-up/#findComment-384490 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.