Jump to content

validation by activation link in email pls help


youngbuzz
 Share

Recommended Posts

hey friends this is my register.php i want to add validation by sending activation link in email to my users , pls help . this is my register.php<?php include ("......php"); include ("....php"); echo("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD XHTML Mobile 1.0//EN\"". " \"http://www.wapforum.org/DTD/xhtml-mobile10.dtd\">";?><html xmlns="http://www.w3.org/1999/xhtml"><head><title>Registration</title><meta forua="true" http-equiv="Cache-Control" content="no-cache"/><meta forua="true" http-equiv="Cache-Control" content="must-revalidate"/><?php connectdb();echo gettheme($sid); ?></head><body><?php boxstart("Registration");echo "<small>";$uid = $_POST["uid"]; $pwd = $_POST["pwd"]; $bdt = $_POST["bdt"]; $bdu = $_POST["bdu"];$bdv = $_POST["bdv"];$email=$_POST["email"];$bdy = $bdv."-".$bdu."-".$bdt;$cpw = $_POST["cpw"];$###### = $_POST["usex"];$location = $_POST["uloc"];$likes = $_POST["likes"];$hates = $_POST["hates"];$ms = $_POST["ms"];$signature = $_POST["signature"];$rname = $_POST["rname"];//$avatar = $_POST["avatar"];$canreg=canreg();if($canreg=='0'){echo "<p align='center'>"; echo "<img src=\"images/notok.gif\" alt=\"X\"/> Registration is presently closed, please try again later."; echo "</p></small></div></div></body></html>";exit();}?> <p>Fields marked with an star(*) are compulsory to be filled.<br/>Allowed characters in username and password are A-Z, space, a-z, 0-9, _ and . only.<br/> Username must begin with a letter and be less than 20 characters long. It may contain spaces. Please enter a valid email address.<br/></p>[ <i>By Registering Here You Agree To Follow Our <a href='http://youngbuzz.net/index.php?action=terms'><u><b>Rules</b></u></a>!</i> ]<br/><? $emailcheck = mysql_fetch_array(mysql_query("SELECT * FROM ibwf_users WHERE email='".$email."'"));if(trim($uid)==""){ echo registerform(1); }else if(trim($pwd)==""){ echo registerform(2); }else if(trim($cpw)==""){ echo registerform(3); }else if(scharin($uid)){ echo registerform(4); }else if(spacesin($pwd)||scharin($pwd)){ echo registerform(5); }else if($pwd!=$cpw){ echo registerform(6); }else if(strlen($uid)<1){ echo registerform(7); } else if(strlen($pwd)<3){echo registerform(8); }else if(isdigitf($uid)){echo registerform(11); }else if(checknick($uid)==1){ echo registerform(12); }else if(checknick($uid)==2) { echo registerform(13);}else if($emailcheck[0]>0){ echo registerform(14); }else if(register($uid,$pwd,$######,$bdy,$location,$rname,$ms,$email)==1){ echo registerform(9); }else if(register($uid,$pwd,$######,$bdy,$location,$rname,$ms,$email)==2){ echo registerform(10); }else {$usid = mysql_fetch_array(mysql_query("SELECT id from ibwf_users WHERE name = '$uid'"));if ($canreg=='2'){$ptime=time()+2*24*60*60;/*$moutb=mysql_query("INSERT INTO ibwf_penalties SET uid='".$usid[0]."', penalty='0', exid='1', timeto='".$ptime."', pnreas='You have just registered.', ipadd='".$REMOTE_ADDR."', browserm='".$HTTP_USER_AGENT."'");$mforb=mysql_query("INSERT INTO ibwf_penalties SET uid='".$usid[0]."', penalty='3', exid='1', timeto='".$ptime."', pnreas='You have just registered.', ipadd='".$REMOTE_ADDR."', browserm='".$HTTP_USER_AGENT."'");$mshob=mysql_query("INSERT INTO ibwf_penalties SET uid='".$usid[0]."', penalty='4', exid='1', timeto='".$ptime."', pnreas='You have just registered.', ipadd='".$REMOTE_ADDR."', browserm='".$HTTP_USER_AGENT."'");$outb = mysql_query("UPDATE ibwf_users SET inboxb='1' WHERE id='".$usid[0]."'");$forb = mysql_query("UPDATE ibwf_users SET forumb='1' WHERE id='".$usid[0]."'");$shob = mysql_query("UPDATE ibwf_users SET shoutb='1' WHERE id='".$usid[0]."'");*/$validrqd = mysql_query("UPDATE ibwf_users SET validrqd='1' WHERE id='".$usid[0]."'");mysql_query("UPDATE ibwf_users SET lastpnreas='You have just registered, please wait until your account gets validated.', ua='$HTTP_USER_AGENT', ip='$REMOTE_ADDR' WHERE id='".$usid[0]."'");/*mysql_query("INSERT INTO ibwf_mlog SET action='Validation Required', details='<b>".getnick_uid($usid[0])."</b> has just registered and is currently awaiting moderation.', actdt='".$ptime."'");*/echo "<p align='center'><b>Registration completed successfully!</b><br/><br/>Your ID is presently awaiting moderation. You can login after it is validated by our mods. This process can take a maximum of 24 hours. Normally it takes less than an hour.</p></small></div></div></body></html>";/*echo "<p><b><br/><br/>Registration completed successfully!!</b>";echo "<br/>You may login now. <a href=\"login.php?loguid=$uid&logpwd=$pwd\">Click here</a> to login.</p></small></div></div></body></html>";*/exit();}else{mysql_query("INSERT INTO ibwf_mlog SET action='penalties', details='$uid has just signed up.', actdt='".time()."'");$logit = mysql_query("UPDATE ibwf_users SET ua='$HTTP_USER_AGENT', ip='$REMOTE_ADDR' WHERE id=$usid[0]");if ($logit) { echo "<p><b>Registration completed successfully!!</b>";echo "<br/>You may login now. <a href=\"login.php?loguid=$uid&logpwd=$pwd\">Click here</a> to login.</p>"; }echo "<p><a href=\"index.php\">Back</a></p>"; echo "</small></div></div></body></html>";exit();} }?> </small></div></div></body></html>

Link to comment
Share on other sites

The tutorial explains the details, but the general idea is pretty simple. The database table for users needs to contain columns to indicate if the user is active, and what their activation key is. When a user registers, you set them to be not active and create a random activation key that doesn't already exist, and save that in the users table in the database. You send them an email which contains a link that has the activation key in it, and the PHP script in the link gets the key, looks up the user in the database that matches the key, and sets their account to active.That is the general idea, and that tutorial has the specific details listed in it. If you have questions about specific pieces of code or the ideas then let us know, but it's hard to answer a general question like you don't know how to incorporate it. Set up the database, set up the code to create an activation key and save it, include the link in the email, and set up the activation script to get the key and activate the account. Each of those steps is easy, you might be looking at the overall picture and thinking it's difficult but it's just a series of small easy steps.

Link to comment
Share on other sites

The tutorial explains the details, but the general idea is pretty simple. The database table for users needs to contain columns to indicate if the user is active, and what their activation key is. When a user registers, you set them to be not active and create a random activation key that doesn't already exist, and save that in the users table in the database. You send them an email which contains a link that has the activation key in it, and the PHP script in the link gets the key, looks up the user in the database that matches the key, and sets their account to active.That is the general idea, and that tutorial has the specific details listed in it. If you have questions about specific pieces of code or the ideas then let us know, but it's hard to answer a general question like you don't know how to incorporate it. Set up the database, set up the code to create an activation key and save it, include the link in the email, and set up the activation script to get the key and activate the account. Each of those steps is easy, you might be looking at the overall picture and thinking it's difficult but it's just a series of small easy steps.
oh m sorry sir , i modified this in register.php now but i m getting error as NO CODE SUPPLIED , when i click the link sent in email , THIS IS MY register.php if ($canreg=='2'){$ptime=time()+2*24*60*60;/*$moutb=mysql_query("INSERT INTO ibwf_penalties SET uid='".$usid[0]."', penalty='0', exid='1', timeto='".$ptime."', pnreas='You have just registered.', ipadd='".$REMOTE_ADDR."', browserm='".$HTTP_USER_AGENT."'");$mforb=mysql_query("INSERT INTO ibwf_penalties SET uid='".$usid[0]."', penalty='3', exid='1', timeto='".$ptime."', pnreas='You have just registered.', ipadd='".$REMOTE_ADDR."', browserm='".$HTTP_USER_AGENT."'");$mshob=mysql_query("INSERT INTO ibwf_penalties SET uid='".$usid[0]."', penalty='4', exid='1', timeto='".$ptime."', pnreas='You have just registered.', ipadd='".$REMOTE_ADDR."', browserm='".$HTTP_USER_AGENT."'");$outb = mysql_query("UPDATE ibwf_users SET inboxb='1' WHERE id='".$usid[0]."'");$forb = mysql_query("UPDATE ibwf_users SET forumb='1' WHERE id='".$usid[0]."'");$shob = mysql_query("UPDATE ibwf_users SET shoutb='1' WHERE id='".$usid[0]."'");*///function genRandomString() { $length = 10; $characters = ’0123456789abcdefghijklmnopqrstuvwxyz’; $string = ”; for ($p = 0; $p < $length; $p++) { $string .= $characters[mt_rand(0, strlen($characters))]; } return $string;}$validation_code = genRandomString();##Send activation Email$to = $_POST;$subject = " YOURWEBSITE.com Registration";$message = "Welcome to our website!\r\rYou, or someone using your email address, has completed registration at YOURWEBSITE.com. You can complete registration by clicking the following link:\rhttp://www.YOURWEBSITE.com/activate.php?$validation_code\r\rIf this is an error, ignore this email and you will be removed from our mailing list.\r\rRegards,\ YOURWEBSITE.com Team";$headers = 'From: noreply@ YOURWEBSITE.com' . "\r\n" . 'Reply-To: noreply@ YOURWEBSITE.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); if (!mail($to, $subject, $message, $headers))echo "We couldn't sign you up at this time. Please try again later."; else { //register into database $register = mysql_query("INSERT INTO ibwf_users (name, pass, email, code, active) VALUES ('$uid','$pwd','$email','$validation_code','0')"); echo "You have been registered successfully! Please check your email ($email) to activate your account"; } } }echo "<p><a href=\"index.php\">Back</a></p>"; echo "</small></div></div></body></html>";exit();?> AND NOW ACTIVATE.PHP ( i have 2 columns added in my users tables CODE and ACTIVE <?phpinclude 'config.php';$code = $_GET['code'];if (!$code) echo "No code supplied";else{ $check = mysql_query("SELECT * FROM ibwf_users WHERE code='$code' AND active='1'"); if (mysql_num_rows($check)==1) echo "You have already activated your account"; else { $activate = mysql_query("UPDATE ibwf_users SET active='1' WHERE code='$code'"); echo "Your account has been activated!"; } }?> (DNT KNOW WHY the code is not inserted in database)
Link to comment
Share on other sites

If you want to use $_GET['code'], then the URL needs to include the name "code" for the value. Right now in your URL there is no name for the variable, so the code would be in $_SERVER['QUERY_STRING'].
uhmm didnt understand , oh my why i m getting this not acceptable error today , pls correct the code sir , where did i go wrong
Link to comment
Share on other sites

uhmm didnt understand , oh my why i m getting this not acceptable error today , pls correct the code sir , where did i go wrong
he's saying your url should look something like:
http://www.yourdomain.com?code=value

the tutorials has a information on this topic if you want to read up on it...http://www.w3schools.com/php/php_forms.asphttp://www.w3schools.com/php/php_get.aspor else use the other technique.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...