LearningKid Posted August 12, 2009 Share Posted August 12, 2009 hi im creating a registration form now after the applicants register i would to send them an activation mail so tht they can activate their accounts however i honestly dont know how to do it. i'll show you what i have so far. register.php <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Example for Validator</title> <Style> BODY, P,TD{ font-family: Arial,Verdana,Helvetica, sans-serif; font-size: 10pt } A{font-family: Arial,Verdana,Helvetica, sans-serif;} B { font-family : Arial, Helvetica, sans-serif; font-size : 12px; font-weight : bold;} .error_strings{ font-family:Verdana; font-size:10px; color:#660000;} </Style> <script language="JavaScript" src="gen_validatorv31.js" type="text/javascript"></script> </head> <body> <form name="myform" ACTION="reg.php" METHOD=get> <table cellspacing="2" cellpadding="2" border="0" align="center"> <tr> <td align="right">*Username</td> <td><input type="text" name="username"></td> </tr> <tr> <td align="right">*Password</td> <td><input type="password" name="password1"></td> </tr> <tr> <td align="right">*Re-enter Password</td> <td><input type="password" name="password2"></td> </tr> <tr> <td align="right">*First Name</td> <td><input type="text" name="FirstName"></td> </tr> <tr> <td align="right">*Last Name</td> <td><input type="text" name="LastName"></td> </tr> <tr> <td align="right">Company</td> <td><input type="text" name="company"></td> </tr> <tr> <td align="right">Position</td> <td><input type="text" name="position"></td> </tr> <tr> <td align="right">*EMail</td> <td><input type="text" name="Email"></td> </tr> <tr> <td align="right">*Re-enter EMail</td> <td><input type="text" name="Email1"></td> </tr> <tr> <td align="right">*Daytime Number</td> <td><input type="text" name="Phone"></td> </tr> <tr> <td align="right">Other Number</td> <td><input type="text" name="Phone2"></td> </tr> <tr> <td align="right">*Address</td> <td><textarea cols="20" rows="5" name="Address"></textarea></td> </tr> <tr> <td align="right">*City</td> <td> <SELECT name="City"> <option value="" selected>[choose yours] <option>Parika <option>Georgetown <option>New Amsterdam </SELECT> </td> </tr> <tr> <td align="right">*County</td> <td> <SELECT name="County"> <option value="" selected>[choose yours] <option>Essequibo <option>Demerara <option>Berbice </SELECT> </td> </tr> <tr> <td align="right">*Security Question</td> <td> <SELECT name="sec_ques"> <option value="" selected>[choose yours] <option>What is my name? <option>Where do I live? <option>My Favourite Pet </SELECT> </td> </tr> <tr> <td align="right">*Answer</td> <td><input type="password" name="sec_ans"></td> </tr> <tr> <td align="right"><input type="checkbox" name="ckb"></td> <td>Please check here if you would like to receive special offers,<br>notification of valuable promotions via company mailings,<br>email contact, telemarketing, catalogues, etc., from us.<br>(Note: You can unsubscribe at any time.)</td> </tr> <tr> <td align="right"><input type="checkbox" name="ckb2"></td> <td>Please check here if you are a business customer</td> </tr> <tr> <td align="right"></td> <td> <div id='myform_errorloc' class='error_strings'> </div> </td> </tr> <tr> <td align="right"></td> <td><input type="submit" value="Submit"></td> </tr> </table> </form> <script language="JavaScript" type="text/javascript"> //You should create the validator only after the definition of the HTML form var frmvalidator = new Validator("myform"); frmvalidator.EnableOnPageErrorDisplaySingleBox(); frmvalidator.EnableMsgsTogether(); frmvalidator.addValidation("username","req","Please enter your Username"); frmvalidator.addValidation("username","maxlen=20","For Username, Max length is 20"); frmvalidator.addValidation("FirstName","req","Please enter your First Name"); frmvalidator.addValidation("FirstName","maxlen=20", "Max length for FirstName is 20"); frmvalidator.addValidation("FirstName","alpha_s","Name can contain alphabetic chars only"); frmvalidator.addValidation("LastName","req","Please enter your Last Name"); frmvalidator.addValidation("LastName","maxlen=20","For LastName, Max length is 20"); frmvalidator.addValidation("Email","maxlen=50"); frmvalidator.addValidation("Email","req"); frmvalidator.addValidation("Email","email"); frmvalidator.addValidation("Phone","maxlen=11"); frmvalidator.addValidation("Phone","numeric"); frmvalidator.addValidation("Phone","req","Please Enter a Daytime Number"); frmvalidator.addValidation("City","req"); frmvalidator.addValidation("Address","maxlen=50"); frmvalidator.addValidation("County","req","Please select your County"); frmvalidator.addValidation("sec_ques","req","Please enter your Security Question"); frmvalidator.addValidation("sec_ans","req","Please enter your Answer"); function DoCustomValidation() { var frm = document.forms["myform"]; if(frm.FirstName.value == 'Anil') { sfm_show_error_msg("Anil, you can't submit this form. Go away! "); return false; } else { return true; } } frmvalidator.setAddnlValidationFunction("DoCustomValidation"); </script> </body> </html> reg.php <?php if($_GET["username"] && $_GET["password1"] && $_GET["password2"] && $_GET["FirstName"] && $_GET["LastName"] && $_GET["Email"] && $_GET["Email1"] && $_GET["Phone"] && $_GET["Phone2"] && $_GET["Address"] && $_GET["County"] && $_GET["City"] && $_GET["sec_ques"] && $_GET["sec_ans"] ) { if($_GET["password1"]==$_GET["password2"]) { if ($_GET["Email"]==$_GET["Email1"]) { $servername="localhost"; $username="root"; $conn= mysql_connect($servername,$username)or die(mysql_error()); mysql_select_db("test",$conn); $sql="insert into customers (username,password,email,first_name,last_name,county,city,street_address,tel_number,second_number,security_quest,security_answer) values('$_GET[username]','$_GET[password1]','$_GET[FirstName]','$_GET[LastName]','$_GET', '$_GET[Phone]','$_GET[Phone2]','$_GET[Address]','$_GET[County]','$_GET[City]','$_GET[sec_ques]', '$_GET[sec_ans]')"; $result=mysql_query($sql,$conn) or die(mysql_error()); print "<h1>you have registered sucessfully</h1>"; print "<a href='register.php'>go to login page</a>"; } else print "Email doesnt match"; } else print "passwords doesnt match"; } else print"invaild data"; ?> would really appreciate the help. Link to comment https://forums.phpfreaks.com/topic/169922-help-with-email-activation/ Share on other sites More sharing options...
trq Posted August 12, 2009 Share Posted August 12, 2009 And your question is? Link to comment https://forums.phpfreaks.com/topic/169922-help-with-email-activation/#findComment-896398 Share on other sites More sharing options...
Lyleyboy Posted August 12, 2009 Share Posted August 12, 2009 The really easy way to do it is to add a flag field called active to the customers table and set it by default to 'off' Then a new user is added create and send an email with a link in it. Set the link to be something like www.mydomain.com/validate_email.php?id=33 where 33 is the id of the user you just entered Then the validate_email.php page takes the $_get['id'] which is currently 33 and finds the record where 33 is the id and updates the active flag to on. Now in the rest of your program you need to add the where clause to your queries. i.e. WHERE active='on' Hope that helps. Link to comment https://forums.phpfreaks.com/topic/169922-help-with-email-activation/#findComment-896399 Share on other sites More sharing options...
LearningKid Posted August 12, 2009 Author Share Posted August 12, 2009 And your question is? sry its how to send an activation mail to the person registering b4 their accounts bcome actice. Link to comment https://forums.phpfreaks.com/topic/169922-help-with-email-activation/#findComment-896413 Share on other sites More sharing options...
LearningKid Posted August 12, 2009 Author Share Posted August 12, 2009 The really easy way to do it is to add a flag field called active to the customers table and set it by default to 'off' Then a new user is added create and send an email with a link in it. Set the link to be something like www.mydomain.com/validate_email.php?id=33 where 33 is the id of the user you just entered Then the validate_email.php page takes the $_get['id'] which is currently 33 and finds the record where 33 is the id and updates the active flag to on. Now in the rest of your program you need to add the where clause to your queries. i.e. WHERE active='on' Hope that helps. That sounds easy but im new at this thing so im gonna try and figure out the flag field thing, but it would be nice if u could give me some ideas as to how to do it thank you. Link to comment https://forums.phpfreaks.com/topic/169922-help-with-email-activation/#findComment-896426 Share on other sites More sharing options...
Lyleyboy Posted August 12, 2009 Share Posted August 12, 2009 Ok, So we have a few steps to do. 1, In you customers table add a field at the end called 'active', set it to a varchar(3) and set the default value to 'off'. 2, When you're adding the details to the table make sure and set the active to off. 3, Now you need to do a query to find the last user you pumped in. $query = "SELECT * FROM customers order by id DESC LIMIT 0, 1"; //Assuming your ID is set to id $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ $users_id = $row['id']; } 4, At the end of your program when it has added the user to the table get it to send an email. One of the lines in the $body variable needs to be the bit that gives out the link to click. Something like $body.="http://www.you.com/validate_email.php?id=" . $users_id; So that the link will look like http://www.you.com/validate_email.php?id=33 assuming that the result of the query in point 3 is 33 5, Now when the user gets the email they click the link and go to your new flashy validate_email.php program. //Setup the id $id = $_get['id']; //Update the table mysql_query("UPDATE customers SET active = 'on' WHERE user_id='$id'"); Now the user can log in. You have to edit all the scripts that control who is able to login as all the queries now need to include a where clause like WHERE active='on' You can also use this kind of thing to lock people out etc. I hope that helps you. Link to comment https://forums.phpfreaks.com/topic/169922-help-with-email-activation/#findComment-896551 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.