Anda mungkin sering melihat sebuah form registrasi yang begitu Anda melakukan registrasi, Anda akan mendapatkan email notifikasi dan link untuk melakukan validasi terhadap account yang baru Anda buat. Tutorial ini sangat mudah untuk diikuti.
Lihat sumber artikel asli: http://cookbooks.adobe.com/post_Registration_form_that_will_email_for_registran_to-16643.html
Note: Form di dalam tutorial ini tidak dilengkapi dengan filter. Anda dapat menambahkannya sendiri.
Problem
i have a good registration system with login (dw cs4 David’s book), but would like to expand or add to it. The user enter all info in registration form, including email, and then an email is sent to user for validation before they can log in.
Solution
This question actually is from RJWeb. In this solution, we will use these files: 1. Register.php, a page where the registration form is displayed 2. Register_ok.php, this page will send an email as notification to registrant to activate their account. 3. Register_error.php, notification page if the registration process failed 4. Activate.php, a page contain link for activation 5. Admin.php, admin page. Only can be accessed by admin/member who has access level 1.
Detailed explanation
This recipe request actually is from RJWeb, one of the Adobe Cookbook user.
Source code: adobe_cookbooks_start.rar and adobe_cookbooks_end.rar
A MySQL table called admin:
01 |
CREATE TABLE IF NOT EXISTS `admin` ( |
02 |
`id` int(10) NOT NULL AUTO_INCREMENT, |
03 |
`name` varchar(64) NOT NULL, |
04 |
`email` varchar(64) NOT NULL, |
05 |
`username` varchar(64) NOT NULL, |
06 |
`password` varchar(64) NOT NULL, |
07 |
`activation` varchar(64) NOT NULL, |
08 |
`level` int(2) NOT NULL DEFAULT '0' , |
09 |
`date_registered` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, |
11 |
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; |
14 |
-- Dumping data untuk tabel `admin` |
17 |
INSERT INTO `admin` (`id`, `name`, `email`, `username`, `password`, `activation`, `level`, `date_registered`) VALUES |
18 |
(1, 'Andoyo' , 'andoyoandoyo@gmail.com' , 'andoyo' , 'andoyo' , '8e67d638c0d130a4d66b2888ffc8335b' , 0, '2011-09-21 10:32:16' ); |
The level column of this table is set zero (0). The admin/member who has 0 access level wil can not access admin page (admin.php).
- Firstly, download the source code above and extract all of them to your web/site root.
- Upload/export the MySQL table.
- Make your site definiton (Site Setup)
- Make your database connection. In this case a database connection file was made, called: adobe_cookbooks.php,
Registration page: register.php
- Open file: register.php. We will build a registration form under the text “Registration page”.
- Click Insert > Data Objects > Insert Record > Record Insertion Form Wizard . The window Insertion form wizard will come out (Figure 1).
- Connection: adobe_cookbooks
- Table: admin
- After inserting, go to: register_ok.php. You can click Browse to find the file: register_ok.php.
- In the Form Fields menu, you can see there Plus sign (+) for Add item and Minus sign (-) for Remove item. At the bottom of that signs there are some columns that we want to insert in.
- Remove the id item by clicking id column, then click Minus sign (-). The id column will be generated automatically by MySQL.
- Do the same for the date_registered and level column. Remove both of the columns. The date_registered is set automatically by MySQL and level is set zero (0) value as a default.
- Click username column.
- Display as: Password field
- Click activation column.
- Display as: hidden field . The activation column will be set as a hidden value. The value will be same as username column but encrypted using MD5 (or SHA1).
- Click OK to finish it.
- Save your file
Ammend the code in register.php
In the Code View, find this code:
1 |
if ((isset( $_POST [ "MM_insert" ])) && ( $_POST [ "MM_insert" ] == "form1" )) { |
2 |
$insertSQL = sprintf( "INSERT INTO `admin` (name, email, username, password, activation) VALUES (%s, %s, %s, %s, %s)" , |
3 |
GetSQLValueString( $_POST [ 'name' ], "text" ), |
4 |
GetSQLValueString( $_POST [ 'email' ], "text" ), |
5 |
GetSQLValueString( $_POST [ 'username' ], "text" ), |
6 |
GetSQLValueString( $_POST [ 'password' ], "text" ), |
7 |
GetSQLValueString( $_POST [ 'activation' ], "text" )); |
We will add a new variable called $my_activation, where the value is same as $_POST[‘username’] encrypted using MD5. The changing of the code will be like this:
01 |
if ((isset( $_POST [ "MM_insert" ])) && ( $_POST [ "MM_insert" ] == "form1" )) { |
02 |
<strong> $my_activation = md5( $_POST [ 'username' ]);</strong> |
03 |
$insertSQL = sprintf( "INSERT INTO `admin` (name, email, username, password, activation) VALUES (%s, %s, %s, %s, %s)" , |
04 |
GetSQLValueString( $_POST [ 'name' ], "text" ), |
05 |
GetSQLValueString( $_POST [ 'email' ], "text" ), |
06 |
GetSQLValueString( $_POST [ 'username' ], "text" ), |
07 |
GetSQLValueString( $_POST [ 'password' ], "text" ), |
09 |
<strong>GetSQLValueString( $my_activation , "text" ));</strong> |
Save your register.php file and try it through your browser.
Sending a notification email: register_ok.php
After a visitor fill all of the information through the form and click Insert record, he/she will be redirected to register_ok.php page. An email script will send the activation link to the email.
- Open file: register_ok.php
- Click Insert > Data Objects > Recordset . The Recordset window will come out.
- Name: rsOK
- Connection: adobe_cookbooks
- Table: admin
- Column: All
- Sort: id , and Descending
- Click Advanced, ammend this code: SELECT *
- Type LIMIT 1 after ORDER BY id DESC. The new code will be like this: SELECT *
2 |
ORDER BY id DESC LIMIT 1 |
- Klik OK
- Save your file
Add PHP Mail function in your code:
After this PHP Code:
1 |
mysql_select_db( $database_adobe_cookbooks , $adobe_cookbooks ); |
2 |
$query_rsOK = "SELECT * FROM `admin` ORDER BY id DESC LIMIT 1" ; |
3 |
$rsOK = mysql_query( $query_rsOK , $adobe_cookbooks ) or die (mysql_error()); |
4 |
$row_rsOK = mysql_fetch_assoc( $rsOK ); |
5 |
$totalRows_rsOK = mysql_num_rows( $rsOK ); |
Press enter to make some spaces, and then add the following code:
01 |
$my_activation = $row_rsOK [ 'activation' ]; |
02 |
$to = $row_rsOK [ 'email' ]; |
03 |
$subject = "Hi " . $row_rsOK [ 'name' ]; |
04 |
$body = "<html><body>" . |
05 |
"<h2>Thank you for your registration.</h2>" . |
06 |
"<p>To active your account, please visit this link</p>" . |
08 |
"From: Webmaster www.javawebmedia.com" ; |
09 |
$headers = "From: Webmaster Java Web Media <contact@javawebmedia.com>\r\n" . |
10 |
"MIME-Version: 1.0\r\n" . |
11 |
"Content-type: text/html; charset=UTF-8" ; |
13 |
if (!mail( $to , $subject , $body , $headers )) { |
14 |
$redirect = "register_error.php" ; |
15 |
header( "Location: " . $redirect ) ; |
So the code will be like this:
01 |
mysql_select_db( $database_adobe_cookbooks , $adobe_cookbooks ); |
02 |
$query_rsOK = "SELECT * FROM `admin` ORDER BY id DESC LIMIT 1" ; |
03 |
$rsOK = mysql_query( $query_rsOK , $adobe_cookbooks ) or die (mysql_error()); |
04 |
$row_rsOK = mysql_fetch_assoc( $rsOK ); |
05 |
$totalRows_rsOK = mysql_num_rows( $rsOK ); |
07 |
$my_activation = $row_rsOK [ 'activation' ]; |
08 |
$to = $row_rsOK [ 'email' ]; |
09 |
$subject = "Hi " . $row_rsOK [ 'name' ]; |
10 |
$body = "<html><body>" . |
11 |
"<h2>Thank you for your registration.</h2>" . |
12 |
"<p>To active your account, please visit this link</p>" . |
14 |
"From: Webmaster www.javawebmedia.com" ; |
15 |
$headers = "From: Webmaster Java Web Media <contact@javawebmedia.com>\r\n" . |
16 |
"MIME-Version: 1.0\r\n" . |
17 |
"Content-type: text/html; charset=UTF-8" ; |
19 |
if (!mail( $to , $subject , $body , $headers )) { |
20 |
$redirect = "register_error.php" ; |
21 |
header( "Location: " . $redirect ) ; |
I add some variable in that code, they are:
- $my_activation, as a random string generated using MD5 has to make a link
- $to, as an email address owned by the last registrant.
- $redirect, as a redirection page if the registration process is failed.
Account activation: activate.php
The next step is activating your account. The member/admin will get an email contain activation link. For example the link could be like this http://localhost/adobe_cookbooks/activate.php?activation=8e67d638c0d130a4d66b2888ffc8335b.
Make a recordset with link parameter:
- Open file: activate.php
- Open file: register_ok.php
- Click Insert > Data Objects > Recordset . The Recordset window will come out.
- Name: rsActivate
- Connection: adobe_cookbooks
- Table: admin
- Column: All
- Filter: activation, URL Parameter, =, activation.
- Click OK
Make an update form to activate the account:
- Click Insert > Data Objects > Update Record > Record Update Form Wizard . The window will come out.
- Connection: adobe_cookbooks
- Table to update: admin
- Select record from: rsActivate
- Unique key column: activation. Uncheck the Numeric option.
- After updating, go to: login.php,
- In the Form fields: option, do the following action.
- Click id column ,
- Remove it by clicking the Minus sign (-)
- Do the same as step 8-9 to these columns: name, email, username, password, activation, and date_registered . Remove all of them by clicking Minus sign (-)
- Click level column
- Display as: Hidden field
- Default value: 1 , clean this default PHP Code: <?php echo htmlentities($row_rsActivate[‘level’], ENT_COMPAT, ‘utf-8’); ?> and change it into 1.
- Click OK
- Save your file
Make your form more readable for the visitors:
In code view, see this code:
1 |
<form action= "<?php echo $editFormAction; ?>" method= "post" name= "form1" id= "form1" > |
4 |
<td nowrap= "nowrap" align= "right" > </td> |
5 |
<td><input type= "submit" value= "Update record" /></td> |
Ammend that code to be like this:
1 |
<form action= "<?php echo $editFormAction; ?>" method= "post" name= "form1" id= "form1" > |
4 |
<td nowrap= "nowrap" align= "right" >Hi <strong><?php echo $row_rsActivate [ 'name' ]; ?></strong>. Activate your account by clicking Activate button.</td> |
5 |
<td><input type= "submit" value= "Activate my account" /></td> |
This form change the level column where the value is set zero value (0) and change it into 1 (one) as an access level. After the activation is done, the user will be redirected to the login page (login.php).
Make your login form: login.php
The next step is make your login page.
Make the login form:
- Open file: login.php
- In Design View, press Enter after the text “Login Page”
- Click Insert > Form > Form
- Click Insert > Form > Text Field . The window will come out
- ID: username
- Label: Username:
- Click OK.
- In Design View, put your cursor after the text field and press Enter
- ID: password
- Label: Password:
- Click OK.
- Change this code: <input type=”text” name=”password” id=”password” /> to be like this: <input type=”password” name=”password” id=”password” />. Thats mean we change the type=”text” to be type=”password”. After the password field, press Enter.
-
Click Insert > Form > Button
-
ID: Submit,
-
Clik OK
Activating login form:
- Click Insert > Data Objects > User Authentication > Log In User
- Get input from form: form1
- Username field: username
- Password field: password
- Validate using connection: adobe_cookbooks
- Table: admin
- Username column: username, click pop up menu to choose it
- Password column: password
- If login succesds, go to: admin.php
- Select the option by clicking it: Go to Previous URL (if exist)
- If login fails, go to: login.php
- Restrict access based on: username, password, and access level.
- Get level from: level, click the pop up menu
- Click OK
- Save your work
Restrict admin page: admin.php
The next step is make sure that admin page only can be accessed after the user logged in.
Protect the page:
- Open file: admin.php
- Click Insert > Data Objects > User Authentication > Restrict Access To Page
- Restrict access based on: username, password, and access level.
- Click Define to make a new access level
- Name: 1, type it manually
- Click Plus sign (+)
- Click OK
- Select level(s): 1, make sure you selected 1 .
- If access denied, go to: login.php
- Click OK
- Save your work
Log Out link:
- In Design View, select “Log Out” text.
- Click Insert > Data Objects > User Authentication > Log Ou User
- Log Out When: Link Clicked: Selection: “Log Out”
- When done, go to: index.php
- Click OK
- Save your work.
Source code: adobe_cookbooks_start.rar and adobe_cookbooks_end.rar
Excellent blog right here! Additionally your website loads up fast! What web host are you the usage of? Can I get your affiliate link on your host? I desire my website loaded up as quickly as yours lol
I used to be suggested this website by means of my cousin. I am not sure whether this publish is written through him as no one else understand such exact approximately my trouble. You are amazing! Thanks!
Sorry, unfortunately I have to debate with this blog post. But nevertheless, I fully comprehend that in fact all of us all have our different emotions.
Unquestionably consider that that you stated. Your favourite justification appeared to be at the net the simplest factor to take into accout of. I say to you, I certainly get irked while people consider worries that they just do not understand about. You managed to hit the nail upon the highest and also outlined out the whole thing without having side-effects , other folks could take a signal. Will likely be back to get more. Thank you
big thanks… nemu disini akhirnya
Nearly all of the opinions on this webpage dont make sense.
Currently, the physicians know that physiological factors are present in the most men who suffer from erectile
dysfunction. Many medicines cause problems with sexual function
like erectile dysfunction including drugs prescribed for high
blood pressure, depression, heart disease and prostate cancer.
Visit this web resource for more info related to Purchase Viagra Online Without Prescription.
Hey! This post could not be written any better! Reading this post reminds me of
my previous room mate! He always kept chatting about this.
I will forward this post to him. Fairly certain he will have a good
read. Thanks for sharing!
I’m really inspired along with your writing abilities and also with
the structure to your weblog. Is that this a paid subject or did
you customize it your self? Anyway stay up the nice quality writing, it’s uncommon to
see a nice weblog like this one today..
Everything is very open with a very clear
explanation of the issues. It was definitely informative.
Your site is very useful. Thanks for sharing!
This is a natural occurrence and can be easily mistaken for acne.
The job of acne skin care products to help normalize shedding into the pore to prevent blockages from occurring, killing the Propionibacterium acnes, and reducing inflammation. Pure genuine pearl powder does not totally
dissolve in water or liquid, so be sure you stir as you drink.
I see you share interesting things here, you can earn some extra cash, your
website has big potential, for the monetizing method, just type in google – K2 advices how to monetize a website
Excellent web site you’ve got here.. It’s difficult to find high-quality writing like yours these days.
I truly appreciate individuals like you! Take care!!
It will also increase the ranking of your website on search
engines and will drive more traffic to your website. It has the
highest ROI (Return of Invesment) in all advertisement channels.
There are other ways to improve your ranking in Googlemaps, the
purpose of this blog post is not to tell you EVERYTHING
Frederick Web Promotions can do to improve your ranking, the purpose of this particular blog post is to:.
My blog post Google
Heyy I know this is off topic bbut I was wodering if you knew of any widgets I coud add to my blog that automatically tweet my newest twitter updates.
I’ve been looking for a plug-in like this for quite some time and was hoping maybe
yyou would have some experience with something like this.
Pleaqse leet me know if you run into anything. I truly enjoy reading your blog and I look forward
to your new updates.
I couldn’t resist commenting. Very well written!
When I originally commented I clicked tthe “Notify me when new comments are added” checkbox and now each
time a comment is added I get four e-mails with the same comment.
Is there anyy way you can remove me from that service?
Thanks!
my web blog :: deborah dolen twitter
Over-the-Road Transportation, Direct Contract Truck Services,
Truck Brokerage, Local Drayage, Intermodal Transportation, Direct
Contract, Railroad Supplied Intermodal Equipment, Third Party
Supplied Intermodal Equipment, Ocean Container Domestic, LTL
Transportation, Interstate, Regional, Domestic Air Brokerage
and Expedited Services are some of the major transport service features of MITCO.
Now fast forward almost seven years later, the company I started is still
viable, profitable and growing exponentially; so exciting.
I’ve been speaking positively about Scentsy so far and you might think that this is like a lot of other company reviews.
Hi it’s me, I am also visiting this web site
regularly, this wweb page is actually nice and the visitors are actually sharing good thoughts.
Feel free to visit myy website weight Loss diet
Oh my goodness! Awesome article dude! Thanks,
However I am having troubles with your RSS.
I don’t now why I cannot subscribe to it. Is there anybody else getting the same RSS
issues? Anybody who knows the solution will you kindly respond?
Thanx!!
My broter suggested I would possibly like this website.
He was once entirely right. This publish truly made my day.
You cann’t consider simply how so much time I hadd spent for this info!
Thanks!
Nothing is hotter this season than the classic shirtdress, which is tailored enough
for work but still exudes a sassy attitude. As much as possible they should have two or more pairs
in their closets. Patterns are perceived as dull by most people, especially
men. If you want to mask a tummy, opt for an empire waist style.
Creating ontologies can be supported using different
techniques and some common tools. SEO company Yule and SEO company Amelia island use the best seo techniques and strategies to get
their clients’ websites on top of search engine result pages.
In most cases, there’s no need to use extremely
fancy graphics, Adobe Flash and other effects.
Ou encore, si vous voulez garder le riz au chaud a la bonne temperature
alors le cuiseur fera l’affaire.
Do you want to have it all – a excellent loved onhes
life and a amazing career too?
Hey there! Quick question that’s entirely off topic. Do you know
how to make your site mobile friendly? My site looks weird when browsing
from my iphone 4. I’m trying to find a theme or plugin that might be able to
correct this issue. If you have any suggestions, please share.
Thanks!
Everything is very open with a really clear explanation of
the challenges. It was truly informative. Your site is very useful.
Many thanks for sharing!
I was excited to uncover this website. I need to to thank you for ones time for this
particularly fantastic read!! I definitely savored every little bit
of it and i also have you saved as a favorite to look at new
things in your web site.
They have different perception of things and react differently in various situations.
In the Videos women are executing to satisfy user’s most erotic fantasy.
MILFs will most like be very protective of their
children it may be awhile before you meet them.
Hello friends, how is the whole thing, and what you wish for to say concerning this piece of writing,
in my view its genuinely awesome for me.
Examine all your maiboxes for verification e-mail.
The conclusion didn’t steve jobs pdf quite pack the punch by
resigning. The show,, is a democratic vision, and never let
him go. The question keeps us guessing with expert skill.
As social media entrepreneurs, we are always
mastering brand new approaches to utilize personal systems, including Twitter.
İçeriğiniz için çok teşekkür ederim
I do not know if it’s just me or if perhaps everyone
else experiencing issues with your blog. It looks like some of the written text within your
posts are running off the screen. Can someone else please provide feedback and let me know if
this is happening to them as well? This might be a issue with my
browser because I’ve had this happen previously. Thanks
OBAT PENGGUGUR KANDUNGAN
buy seo