Registration Script
85,764 ViewsPHP Tutorials March 8th, 2007
In this tutorial you will learn how to create a fully featured registration script, users will be able to enter your site, visit the registration page, fill in the info, submit the form, receive an activation e-mail and be able to activate there accounts.
Alright, this tutorial won't teach you anything about design, so the finalized script won't look pretty at all, but it is very easy to implement into any design.
First, we are going to need to create a table in our database so that we can store all of our registration info. We are going to call this table, users since that's what it will store!
-
CREATE TABLE users (
-
id INT(11) NOT NULL AUTO_INCREMENT,
-
username VARCHAR(30) NOT NULL,
-
password CHAR(40) NOT NULL,
-
email VARCHAR(70),
-
active CHAR(32),
-
PRIMARY KEY(id)
-
);
That little SQL creates our table to store all of our user information in, now we need a way to connect to the database.
-
<?php
-
// CHANGE THESE VALUES
-
-
$dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error());
-
-
?>
This is just a file that we can use to connect to our database with, now all we need to do is include it any file that we want to query the database from.
Now that we have our table and mysql connection file setup, we need to create the PHP file that allows the person to register.
Let's start off by creating the form processing part of the file, it will be included in the same file as the form.
This part is easy, all it does is start a new PHP section, then our first if() statement is saying IF our form is submitted, then continue. We also start a new variable, and assign an array to it. So that we can echo out our errors (if there are any) at the end. We also include our mysql_connect.php file, since we will be querying the database.
-
$query = "SELECT username FROM users WHERE username = '$user'";
-
-
if ($num> 0) {
-
$errors[] = '<font color="red">The username you have chosen has already been taken, please try again.</font>';
-
} else {
-
}
-
} else {
-
$errors[] = '<font color="red">Please provide a valid username between 4 and 30 characters.</font>';
-
}
This is where we check our first field, the username field. We use regular expressions to validate that the username is good. It must only contain numbers, letters, periods and it must be between 4 and 30 characters. If our regular expressions passes all the tests, we query the database and check if the username has been taken, if it has been taking we add an error to our $error array. If it is not taken then we it is assigned to the $username variable.
**UPDATE V1.1** - I have fixed the error that so many people are getting, I made a mistake, I have now added extra security to the script and it should be pretty much bug free.
-
if (!eregi('^[a-zA-Z]+[a-zA-Z0-9_-]*@([a-zA-Z0-9]+){1}(\.[a-zA-Z0-9]+){1,2}', stripslashes(trim($_POST['email'])) )) {
-
$errors[] = '<font color="red">Please provide a valid email address.</font>';
-
} else {
-
}
This little tid-bit of code just validates there e-mail address using another regular expression.
-
if ($_POST['password1'] != $_POST['password2']) {
-
$errors[] = '<font color="red">The 2 passwords you have entered do not match.</font>';
-
} else {
-
$password = $_POST['password1'];
-
}
-
} else {
-
$errors[] = '<font color="red">Please provide a password.</font>';
-
}
This is where we validate our password(s). First we check if they entered in the first password, then if it isn't empty, we make sure that password 1 and password 2 are the exact same (password, and verify password). If they do not match each other, we add an error to our $errors array. If they do match each other, we continue.
-
$query = "INSERT INTO users (username, email, password, active) VALUES ('$username', '$email', SHA('$password'), '$a')";
-
-
-
-
// Send the E-Mail
-
$body = "Thank you for registering at the User Registration site. To activate your account, please click on this link:\n\n";
-
-
// Show thank you message
-
echo '<h3>Thank You!</h3>
-
You have been registered, you have been sent an e-mail to the address you specified before. Please check your e-mails to activate your account.';
-
} else {
-
echo '<font color="red">You could not be registered, please contact us about the problem and we will fix it as soon as we can.</font>';
-
}
This is the part where we do our error checking, if our $errors variable is empty (no errors) then we continue on with the form. So we insert everything into our users table, run the query, then check if it worked using mysql_affected_rows() == 1. If our query only affected 1 row (only inserted 1 user, no more and no less.) then our query worked, you are shown a message and the e-mail is sent to the user.
**UPDATE V1.2** - The query has been fixed, and everything has been personally tested and works now. If there is still more bugs please tell me.
If it didn't work, (the query didn't work) you are shown an error message.
This is the finishing of the PHP section of our registration script, this is always where we check for errors. If the $errors array was not empty then the user is shown an error message and we use a foreach loop to display all of our errors and echo them out to the user. Then we end our PHP section.
-
<h3>Register</h3>
-
<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
-
<p><input type="text" name="username" value="<?php if (isset($_POST['username'])) echo $_POST['username']; ?>" size="30" maxlength="30" /> <small>Username</small></p>
-
-
-
-
-
<p><input type="submit" name="submit" value="Register" /></p>
-
<input type="hidden" name="submitted" value="TRUE" />
-
</form>
So I lied, there is still a little tiny bit of PHP but very simple stuff. Here we just create our form, with the corresponding names as in our PHP script. Make sure you name your the hidden input as submitted, this is how our PHP script knows that the form is submitted.
That is it for our registration part of our script, now we just have to do the activation part, this is a simple little script.
-
<?php
-
$x = (int) $_GET['x'];
-
} else {
-
$x = 0;
-
}
-
$y = $_GET['y'];
-
} else {
-
$y = 0;
-
}
-
-
-
require_once ('mysql_connect.php');
-
$query = "UPDATE users SET active=NULL WHERE (user_id=$x AND active='" . $y . "') LIMIT 1";
-
-
echo "<h3>Your account is now active. You may now log in.</h3>";
-
} else {
-
echo '<p><font color="red" size="+1">Your account could not be activated. Please re-check the link or contact the system administrator.</font></p>';
-
}
-
-
-
} else {
-
-
echo '<b>Activation link not valid!</b>';
-
-
}
-
?>
This is just a simple little script, we start off by checking the x and y values in the URL to check if they are valid (or if someone is messing with us), we inclue our mysql_connect.php file into our script, since we will be using the database to query the right user. A user is considered active when the active field for there name is NULL (empty), so if the x and y values are right and everything works, we then set the active field to NULL. If only 1 account was affected, we echo out a success message and everything is done! If not, then the appropriate error message is echoed and the script stops.
** UPDATE V1.3** - Ok, the last of the escape_data() function bug has been removed (I really hope so) - and everything SHOULD work perfect. I know I've said that in previous versions, but I really mean it this time
If you want to use a login script with this registration script, make sure you check whether or not a user is active or not using a very simple query that selects the active field for the user, and then use an if statement to check whether it is NULL or not.
I hope you have been able to learn something from this script, please send us a comment using our contact form if you have any comments or questions!
**VERSION 1.3** April 16th, 2007- - The last of the escape_data() error has been fixed, (I hope) and everyone can continue on with there lives!
**VERSION 1.2** April 12th, 2007- - The insert query bug is fixed - everything should work perfect.
**VERSION 1.1** April 9th, 2007- - escape_data() function bug is fixed.
Thanks,
Sean

(50 votes, average: 4.3 out of 5)










March 14th, 2007 at 8:32 pm
nicely done, lots of holes but hopefully people clean the input right, like they hsould.
ive always used a simple on/off (1/0) approach to activating accounts via mail.
March 14th, 2007 at 10:25 pm
You are completely right on that, it's definetly not perfect, you could also use a 1/0 approach, which works perfect!
March 14th, 2007 at 11:14 pm
yea, its not a bug in YOUR code necisarilly since it is a tutorial. this way is more interesting than a 1/0 approach
March 15th, 2007 at 1:56 am
I have sent you an e-mail sunjester
March 16th, 2007 at 2:56 pm
Rather than using the DEFINE function I think it would be better to set them as variables, just saves some time really.
Nice tut tho
March 16th, 2007 at 3:09 pm
Ya, you could use it as variables as well, but everyone knows how to use variables, this is just a variation!
Also, when you DEFINE something it is more, set in stone to put it in simple terms.
March 19th, 2007 at 2:59 am
Ya I guess so.
March 20th, 2007 at 3:15 am
HY!
It is super cool this Tutorial and thx for help!
March 20th, 2007 at 11:02 am
Thank you for reading my tutorial, I'm glad you enjoyed it!
March 21st, 2007 at 12:19 pm
Thanks for this gr8 tutorial. User system had always been kind of hitchy for me and now with these powerful basics I can develop on it.
March 21st, 2007 at 1:30 pm
Thanks, Im glad you learned something and I hope you can advance this script to a new level!
March 22nd, 2007 at 10:32 am
hey! great! thanks...
im trying to do that.. but still can't..:) nubie
March 23rd, 2007 at 4:42 pm
Really cool!!
i realy liked it, because its realy well done, and it is easy to modify it or to adapt it to my website without spending too much time.
Great!
March 27th, 2007 at 10:38 am
Im glad that you like it! I hope that you can use it on your site!
March 27th, 2007 at 5:35 pm
It puts escape_data is a undefined function, please help me
April 1st, 2007 at 5:50 am
ncorrect table definition; there can be
only one auto column and it must be defined
as a key
this is what its comming up with
when i have done the first part
April 1st, 2007 at 6:27 pm
@martin - Hmm, no one else has reported having this problem. And there is only 1 auto column.
April 9th, 2007 at 1:09 am
I get the same error as Esteban
Call to undefined function escape_data()
April 9th, 2007 at 4:33 am
I got the same problem of saying "Call to undefined function: escape_data() in /home/lover/public_html/phplearn/registration.php on line 7"
I made the table defination exactly as you said at the first part.
Help please!
April 9th, 2007 at 4:50 am
hello, thanks for the tutorial, still I hav the following error message:
"Fatal error: Call to undefined function escape_data()"
please help me
I do not undersatnd why
April 9th, 2007 at 8:57 am
Hello,
Thanx a lot for this genial tutorial! It's very well explained and easy to understand(and adapt to personal requirements) I'm going to use it for a Members Only Section application. Still as said b4 I really do not undersand the use of the function escape_data... can u please feed me with some information about that
Kr.
April 9th, 2007 at 1:29 pm
Ahh, I have just found the problem. I made a stupid little mistake, it has now been fixed and I have added extra security to the script as well.
If there are anymore errors please feel free to let me know.
April 9th, 2007 at 1:40 pm
Hi Admin
ok just to let you know that the following sql instruction seems not to be correct:
#
$query = "INSERT INTO users (username, email, password, ) VALUES ('$username', '$email', SHA('$password'), '$a')";
#
the activate argument need to be inserted too.
Hey how long are we going to wait for the tutorial with session management based on your script
Thankx again
April 10th, 2007 at 10:55 am
You are actually correct about that as well! I will fix that right now.
Well, for that I would need to create a login script. That would be a good tutorial to write since a login script tutorial and this tutorial would work very well together.
I will make the login script using sessions, and then maybe a variation using cookies.
April 10th, 2007 at 12:40 pm
umm... maybe I'm the only one, but I entered a valid e-mailaddress and it said that it was invalid
April 10th, 2007 at 12:41 pm
furthermore, I would like to say that it's a really great tutorial
Thx a lot!!!!
April 10th, 2007 at 1:01 pm
srry 'bout before:) the e-mailthingie works perfect! it was my mistake...
April 10th, 2007 at 2:06 pm
Ahh, glad to hear you got everything fixed!
Feels good to get it all fixed on your own doesn't it?
April 10th, 2007 at 4:24 pm
admin Says: "I will make the login script using sessions, and then maybe a variation using cookies."
@admin: Hey I've implemented a login script yesterday, but right now I have issues with the session management part ! Anyway it's funny funny to see how it works douh!
April 12th, 2007 at 9:10 am
I get the following error message when I try to use the registration form. Any thoughts anyone?
Warning: mysql_real_escape_string(): Can't connect to local MySQL server through socket '/usr/local/mysql-5.0/data/mysql.sock'
April 12th, 2007 at 10:22 am
An error like that seems to me like it might be because there is no connection for the mysql_real_escape_string to work on. Are you getting any connection errors as well? Or do you connect to the database fine?
April 12th, 2007 at 10:59 pm
Fatal error: Call to undefined function escape_data() in /hosted/subs/ulmb.com/c/r/crimewave/public_html/activate.php on line 16
April 12th, 2007 at 11:09 pm
Fatal error: Call to undefined function escape_data() in /hosted/subs/ulmb.com/c/r/crimewave/public_html/activate.php on line 16
thats the error i got when i tried to activate can anyone help me
April 12th, 2007 at 11:40 pm
also i found out that this isn't right
--------------------------
$query = "INSERT INTO users (username, email, password, active) VALUES ('$username', '$email', SHA('$password'), '$a')";
--------------------------
it should be
--------------------------
$query = "INSERT INTO users (username, email, password, active) VALUES ('$username', '$email', '$password', '$a')";
--------------------------
if not you get a assigned password but i still got that error if anyone can help
April 13th, 2007 at 11:34 am
@Birdbrain:
I prefer to use the sha1-algorithm to save my password! So the query will be now:
$query = "INSERT INTO users (username, email, password, active) VALUES ('$username', '$email', SHA1('$password'), '$a')";
April 13th, 2007 at 12:08 pm
@Serge
Thankz for that tip but you think you can help with this error
Fatal error: Call to undefined function escape_data() in /hosted/subs/ulmb.com/c/r/crimewave/public_html/activate.php on line 16
April 14th, 2007 at 2:05 pm
@Birdbrain24:
Me too I do not understand the why of the error triggered by the function escape_data(). I've just removed it from the code, and it works. What the consequences are, I sincerely don't know yet.
@admin: please tell us more about that escape_data()
April 14th, 2007 at 2:51 pm
@Serge:
I Am Going To Try That! Remove It From The Script And Admin Can Ypu Please Tell You What Removing This Will Do To The Script!
April 16th, 2007 at 9:19 pm
Alright -
You guys are all right. I did have an error by using the escape_data() function. The reason why it gives you an error? Is because it doesn't exist! During the testing stages of my script I did some different things then what the tutorial shows and I forgot about the whole escape_data() function not being used in the tutorial (in other words, the function was never created) and I forgot to take out each of its uses.
Thank you again for pointing all this out, and Serge you were right for taking it out! You fixed the mistake all on your own!
Removing it from your script will not cause any harm, it will just make it work
April 17th, 2007 at 10:18 am
hey Sean - i'm really new to php and mysql and i don't quite get the mysql part. and do i put all these different section into one php file or do i create different files? could you please help me get this set up? thanks so much.
April 17th, 2007 at 9:42 pm
Hey there Annand, yes in the beginning MySQL can be quite the daunting thing to learn. Once you get the basics though it can be quite easy.
Yes you put each of the different sections of code into separate files with the .php extension on the end.
If you need more clarification on anything just leave me a comment. I suggest you reading our tutorials on PHP basics, we currently have 2 in the series.
PHP Basics 2
PHP Beginner Tips
April 23rd, 2007 at 10:19 am
CREATE TABLE `users` (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
`username` VARCHAR( 30 ) NOT NULL ,
`password` CHAR( 40 ) NOT NULL ,
`email` VARCHAR( 70 ) ,
`activate` CHAR( 32 )
)
I have set this up, but im getting this error
"#1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key"
What does that happen to mean?
April 23rd, 2007 at 8:44 pm
@Xeon133 - You totally missed a line in your query there, your ID is defined as auto_increment, which means you need to set it as the tables PRIMARY KEY.
If you will see in the query I have at the top of this tutorial I have this right before the last line -
PRIMARY KEY(id)
That just says which row you want as the PRIMARY KEY, simple enough? That should solve your problem!
April 27th, 2007 at 8:45 pm
can you post a downloadable version of this script, with or without comments??
April 28th, 2007 at 11:13 pm
aooooowwwww
May 1st, 2007 at 6:43 am
Hi, this is simple and easy to understand tutorial and it will work, I will check right now
May 3rd, 2007 at 1:02 pm
Yo to all and admin !
To all
How to check if account activated or not , when use try to login ?
If activation=NULL then check name && pw ?
If not , echo that your account not activated .
Is it right ?
to admin
Thx for this nice site :=) Im enjoying it .
But there is one note ..
CODE IS UNREADABLE ..
Its rly hard to read code and scroll textarea at the same time ..
:///
May 22nd, 2007 at 1:16 pm
I read the following, wasn't quite sure how to go about it, could you provide an example? or would it depend on the user login script that I use? Thanks for your time! Great tutorial as usual!
"If you want to use a login script with this registration script, make sure you check whether or not a user is active or not using a very simple query that selects the active field for the user, and then use an if statement to check whether it is NULL or not."
May 24th, 2007 at 8:39 am
This tutorial would be much more useful if the php script was in a single text box with the comments above the code you are describing. Copying & pasting all the sections of code is very time consuming.
May 31st, 2007 at 9:48 am
Fantastic tutorial, I learned loads. One small problem, your table creates a field called "id" but your activate.php script references this as "user_id". This causes the SQL statement to error & no one can actually get activated.
I just changed the active script to read:
$query = "UPDATE users SET active=NULL WHERE (id=$x AND active='" . $y . "') LIMIT 1";
That is, change "user_id=$x" to "id=$x" and it works great.
May 31st, 2007 at 12:35 pm
Good tutorial. Minor nitpick - in the activate script you have "where (user_id=", but in the database table it's just called "id"...
June 5th, 2007 at 1:14 am
Nice tut m8 good job
June 16th, 2007 at 8:27 pm
Hey thanks for ur tutorial..really great!
Though I have some problem,when I completes my form it says:
Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\xampp\htdocs\xampp\registration\login.php on line 97
Thank You!
-->which come down to ( mail($_POST['email'], 'Registration Confirmation', $body, 'From: root@localhost.com'); ) ...in login.php
and I would go and see php.ini it says:
-->( [mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25
; For Win32 only.
; sendmail_from = me@example.com )
I believe you can solve my problem....it would be great help to me if you could help me.....waiting for ur reply!
June 26th, 2007 at 4:05 am
great tutorial
June 26th, 2007 at 7:53 am
This is great!! It would be wonderful if you include session management to your list of tutorials.
June 30th, 2007 at 2:35 pm
I could not get my accounts to "activate" until I changed one line of code:
$query = "UPDATE users SET active=NULL WHERE (user_id=$x AND active='" . $y . "') LIMIT 1";
TOO
$query = "UPDATE users SET active=NULL WHERE id='$x' AND active='$y' LIMIT 1";
I am a beginner at computer programming so maybe my method is just the simple amateur way or less secure way. Is there any problem though with my method??
July 9th, 2007 at 1:09 pm
Thanks, i am writing the codes and i'll let you know how it goes, Thanks for the Tutorial.
July 11th, 2007 at 4:17 pm
I sucessfully re-wrote the script but i am getting am error saying "Your account could not be activated. Please re-check the link or contact the system administrator."
I also tried Richard's Method and still the same thing. Can you help me out? "Thanks,"
July 20th, 2007 at 4:49 pm
Great tutorial as always
July 24th, 2007 at 4:39 am
I'm getting the same as Duntouch...
any help?
August 1st, 2007 at 4:37 am
Ok, I was having the same problem that you guys were having above, but I put in Richards fix and it started working. dunno why it's not working for you guys but it's working for me. To the guy who wrote the script... thanks ten hundred billion for making and easy to use tutorial.
August 7th, 2007 at 9:03 pm
hi,
worked fine but cause the pwd is sha1 hased in the database if i were to do a forgot password section it would send the hashed pwd how would i do it so it unhashes it then sends it?
August 21st, 2007 at 8:53 pm
I have everything working except when I click on the activation link it says the page is not found. What am I doing wrong?
Thanks
August 24th, 2007 at 4:24 am
Very nice script, great job..
I had to use Richards fix though maybe you should include this update too.
Thx for a great tutorial
August 24th, 2007 at 12:59 pm
can someone tell me how to decode the sha string. or how do i go about verifying during login.
@admin: i have to say .. this is an excellent article. it is explained in very layman terms and has covered in great detail the concepts required in a registration system. the system also has email-activation which is great. keep it up and hope you continue to write similar articles.
@admin: and waiting for the login tutorial, may i know if there is any schedule.
August 24th, 2007 at 1:29 pm
>> can someone tell me how to decode the sha string. or how do i go about verifying during login.
stupid question .. if someone still wants to know how, just get the password from the login form and convert to sha string and compare it with the one in the db.
August 24th, 2007 at 7:23 pm
hey i like the tutorial im am using it for my website btu i need a login script if you cna please make a login script because i cant do it the way it needs to be done
im kinda new to php
September 4th, 2007 at 6:42 pm
I try to activate my account but i don't receive the activate email ...why ?
September 6th, 2007 at 2:10 am
I tried and it is successful
Thanks,
October 4th, 2007 at 3:03 pm
OK, dumb question. I am new at this and have a site ready to publish (close anyway) that needs usernames and passwords that are created through paypal. Do I use this info exactly as is in this tut or do I have to "tweak" somethings? Does it all go in one script? And is it just created in say a .php file. Where do I put it when complete and link it to my login page?
October 5th, 2007 at 8:30 am
I currently am working on a php login script and it is very in depth. I want to integrate your activation script only into mine. where would i place your code. or is it its own seperate file.
October 5th, 2007 at 1:25 pm
i am new newcommer in software and web developement section
but i like full script that is jst cut and paste script
with no exprience of coading
i really dont understand how to use it
thank you
October 6th, 2007 at 12:15 pm
Can I pay you to install the script?
October 6th, 2007 at 12:18 pm
Hello, I'm really stuck. I'm getting some errors when I tried.
1. How many pages should I have
2. The database portion seems to have worked.
Thanks
October 12th, 2007 at 8:14 am
Hi i am creating the website, i have seen this tutorial code, seems quite good, but one thing is missing that is how to include this login script to actual page that is if say for the job site if jobseeker want to see the job listed, then he should first login, second he should fill the data for job search criteria, then the actual joblisting page will display, if login fails he can not fill and visit job search criteria.
Also there are no logout script
November 9th, 2007 at 9:53 am
No matter what I seam to do I can not get the activation to work. I keep getting "Your account could not be activated. Please re-check the link or contact the system administrator."
Any help, please.
November 9th, 2007 at 12:50 pm
I also keep getting the "your account could not be activated" message...also does anyone know how to sign the email message so it is flagged as trusted and not "not trusted"?
November 20th, 2007 at 6:20 am
nice script there!
thank you very much for the info..
but how about the login page?
can you provide us with it?
i also want the cookies to be activated, is it possible?
November 22nd, 2007 at 12:13 pm
hey i have used your script nice but one part puzzles me..
when i submit the form the active field contains a 32 encrypted characters therefore it shows that the account is already activated..leaving the other part useless..is there something that im missing out..
Please help thanx
November 27th, 2007 at 12:31 pm
Here's a login and logout script that might help someone.
a form for yourform.html page:
Username:
Password:
login script for login.php:
and a logout script:
";
?>
Good luck,
Bill
November 27th, 2007 at 12:32 pm
i'll try that again in separate posts:
a form:
Username: Password:
November 27th, 2007 at 12:52 pm
hmm. apparently the form doesn't post any code.. if anyone is really stuck and needs code for a form, login script, and logout script you can email me at bill_php ( at ) comcast.net
- Bill
December 11th, 2007 at 2:03 am
What name should i put for the php files? By the way... How do you even make the database?
January 1st, 2008 at 5:54 am
Hello, This is a very good tutorial for a registration. It worked correctly the first time around 10/10. It can be easily made to look like your own site which i really like. For people who are getting them register errors or account activation errors make sure you have imported your "users" table through the same database you typed in the mysql_connect.php file. Im pretty sure i got an error like this at first but i forgot to import my users table :P.
But good work, to the author who made this.
January 2nd, 2008 at 5:18 am
What Al says
$query = "UPDATE users SET active=NULL WHERE (id=$x AND active='" . $y . "') LIMIT 1";
there is no column user_id in "users"
January 16th, 2008 at 10:44 am
Hey this script is great and works fine after changing the "id" to "user_id" in my database.
But i really need a login script code. Can anyone please help,
Please. email me at craig_roberts01@hotmail.com
Thanks
January 21st, 2008 at 9:51 am
I really appreciate the tutorial. I found it really useful, taught me a lot and just wanted to say thank you.
February 5th, 2008 at 9:13 am
I have done this tutorial and everything is working fine, one of the best registration tutorials I have found but I would like an example as to how to have a field for first name etc implimented into this, simple I know but I'm new to php.
February 10th, 2008 at 11:19 am
Hi.Can this tutorial be used to the top site script?I`m not so good in php/mysql.
February 27th, 2008 at 10:53 am
when i clicked onto the confirmation email, it always says "your account can't be activated". did I get any error while executing the codes? thanks
March 11th, 2008 at 2:09 am
Admin, can u put all files in one package please?
Regards!!
March 11th, 2008 at 12:14 pm
Yes all files in one please
March 14th, 2008 at 7:50 am
WELL....ITS REALY FANTASTIC...CODE..ITS WORKING NICELY ON MY SITE...I REALY WANT TO THANKS TO www.tutorialcode.com
March 14th, 2008 at 7:54 am
SIR ONE THING WANT SAY THAT IS....JUST USE ID IN ACTIVATE.PHP WHERE U HAVE USED USER_ID
March 21st, 2008 at 5:48 am
has anyone figured out how to do a login.php script
if so please let me know.
April 6th, 2008 at 4:29 pm
It's not accepting my host.
Can you do an example of what you'd put into the mysql_connect page please?
I've put it all in correct and it won't accept the host..
April 9th, 2008 at 10:42 am
I'm getting the following text when I click my test activation link: Your account could not be activated. Please re-check the link or contact the system administrator.
April 11th, 2008 at 7:15 pm
There is another great login/registration script at
http://www.easykiss123.com/?p=33
It's a free script and has a video that walks you through setting it up with your existing site.
May 10th, 2008 at 3:25 am
superb scripts
can it work as it is given
May 20th, 2008 at 3:00 pm
Hi, this tutorial is great, i just got my registration form to work. Thanks alot.
May 22nd, 2008 at 7:17 am
Nice tutorial... although its not very tight logic, it gave me an idea where to start and proceed.
Once again a great JOB!!
May 29th, 2008 at 2:56 am
[...] User Registration/Account Activation Script [...]
June 6th, 2008 at 10:36 am
Its Really Very Nice, I am very thank full for the script
but check the fields before use, because in activate.php there is a small mistake in field. is 'user_id' it should be with 'id'
Thank You................
July 6th, 2008 at 4:42 pm
free spyware detecter
July 22nd, 2008 at 9:25 pm
very nice tutorial. thx.
July 23rd, 2008 at 12:42 am
Hi, Really useful and nice thnx ,regards.
July 24th, 2008 at 9:17 pm
it doesn't tell what you name the files =/
August 27th, 2008 at 3:54 pm
Great script !!!
1 problem that i'm having is it tells me that the email address is not valid that I try to register with and I have tried all of mine then hotmail and yaho addresses and nothing.
August 27th, 2008 at 3:59 pm
BTW has anybody created a login script for this. I don't have a problem creating the script its just the decripting of password that I can't do?
http://www.mofiki.com
September 6th, 2008 at 1:58 pm
Hi, im german an i try to speak english^^
this tutorial is great! but i get no confirmation email
X( i think its my misstake, can u help me ??
September 8th, 2008 at 1:35 pm
I tired this script, and its very effective, and I need more of a admin control... I need search on good old google and came to this site http://regform.rmtemplates.com/ check out this script.
September 14th, 2008 at 7:21 pm
[quote]
Al Says:
May 31st, 2007 at 9:48 am
Fantastic tutorial, I learned loads. One small problem, your table creates a field called "id" but your activate.php script references this as "user_id". This causes the SQL statement to error & no one can actually get activated.
I just changed the active script to read:
$query = "UPDATE users SET active=NULL WHERE (id=$x AND active='" . $y . "') LIMIT 1";
That is, change "user_id=$x" to "id=$x" and it works great.
[/quote]
Good job this worked fine
September 21st, 2008 at 5:48 am
I have no clue what to do with this sript. I tried it in a test page - but it kinda just went wrong. Can you please give me a bit of help with this, because it's quite a vital part of what I wanted to do with my website =D. It's a very good tutorial, I thought I might as well point out, the only trouble is that I'm a bit dumb when it comes to javascript. Please can I have some help, though and someone send me just the finished code - if it works like that..? Thanks alot =P
September 21st, 2008 at 6:26 am
You gotta make the tutorial as if you're writing it for reatards, cos I have no clue what i'm meant to have done. Such as at the very top; am I meant to save it as two seperate files, put it in a .htm file? .PHP (if that exists)? I have no clue. I'm gonna try it again anyway. Thanks.
September 21st, 2008 at 6:38 am
Heya. I know I just posted 3 times in a row, but, does anyone know of a tutorial for beginners. A proper dumbo's one that I can understand. Or, does anyone have a simple copy-and-paste script?
September 21st, 2008 at 8:59 am
Heya, and nice script
i have a problem though, i want to implement it to my website, i already have a sql database. Only difference is that my table is named "Accounts" and username is named "Login", i tried to change the values, that should make it post it in the right place. But doesnt, work - i probably missed something, any suggestions?
Thanks in advance
October 26th, 2008 at 4:18 am
Why deleted my question man ?
November 6th, 2008 at 3:55 am
Looking for a script which will show me whether a web page indexed by Google or not.I mean it will show yes if a page indexed and no if page is not indexed by Google the same function which comes when some one puts "cache:URL" at Google search
November 24th, 2008 at 2:57 pm
when i click no register.php everythings fine and at the bottom it says
Activation link not valid!
what do i do...i dont have activate.php either
November 24th, 2008 at 3:17 pm
ok i figured it out but now when users register and click on the link it says this...
Your account could not be activated. Please re-check the link or contact the system administrator.
January 14th, 2009 at 8:25 pm
in the last script, activate.php, change user_id too id or else nobody can activate there user. took me a while to figure it, please update the tut or this wont work for anybody, thx ^^
January 30th, 2009 at 9:29 pm
Most of my code works now, after modification. I can't get the data into the database tables though. I seem to have an extra { and thought I'd solved it but havent.
I even did a cut and paste on the code block and retyped it, but I still can't get it to work.
Any ideas?
February 1st, 2009 at 7:39 pm
Hey, I'm trying this out but the script keeps telling me my email is invalid. I tried a different email regex but it still fails.
February 8th, 2009 at 1:54 pm
I'm not sure why but I keep getting the error message from within the code. "Your account could not be activated. Please re-check the link or contact the system administrator."
Here is my code:
0) && (strlen($y) == 32)) {
require_once ('mysql_connect1.php');
$query = "UPDATE users SET active=NULL WHERE (user_id=$x AND active='" . $y . "') LIMIT 1";
$result = mysql_query($query);
if (mysql_affected_rows() == 1) {
echo "Your account is now active. You may now log in.";
} else {
echo 'Your account could not be activated. Please re-check the link or contact the system administrator.';
}
mysql_close();
} else {
echo 'Activation link not valid!';
}
?>
February 8th, 2009 at 1:55 pm
Sorry, it didn't post all the code.
0) && (strlen($y) == 32)) {
require_once ('mysql_connect1.php');
$query = "UPDATE users SET active=NULL WHERE (user_id=$x AND active='" . $y . "') LIMIT 1";
$result = mysql_query($query);
if (mysql_affected_rows() == 1) {
echo "Your account is now active. You may now log in.";
} else {
echo 'Your account could not be activated. Please re-check the link or contact the system administrator.';
}
mysql_close();
} else {
echo 'Activation link not valid!';
}
?>
February 8th, 2009 at 1:58 pm
I can't seem to get the first part of the code to post. Let me try again.
February 17th, 2009 at 12:34 pm
exceptional tutorial mate,
everything is explained so very easily, and you wont need any more updates, this works perfectly.
thanks
March 26th, 2009 at 10:23 am
What will I named the php script?
action="" Does this means I have to place the form and this php at single file?
March 29th, 2009 at 10:31 am
cant anyone help me ?? I dont get the email. Wheres the part in the source which sends the mail
April 15th, 2009 at 10:23 pm
Wonderful tutorial! I just have one question is there a way to set a time limit for activating an account so that if they do not activate the account in so many days that it will automatically delete the account from the database to keep it nice and clean from people who never activate their accounts?
April 21st, 2009 at 11:44 pm
Hi,
I get this error:
Parse error: syntax error, unexpected '}' in /home/kch1l4p0/public_html/registration.php on line 64
on this portion of the code:
" echo 'You could not be registered, please contact us about the problem and we will fix it as soon as we can.';
//} } else {
echo 'Error!
The following error(s) occured:';
foreach ($errors as $msg) {
echo " - $msg\n";
}
}
}
?>"
in order for this not to happen I had to comment line 64, as you see.
If I erased the 'unexpected }' then I would get an 'unexpedted T_ELSE' -
What could be wrong with my code? I copied it from the page exactly.
April 29th, 2009 at 9:56 pm
Are you going to put Login form tutorial (with session and cookies) to support this Registration script?
If yes, when will be possible for us to go through? Without Login script, Registration script tutorial is leaving our work incomplete.
May 3rd, 2009 at 11:06 am
Hi,
Thanks for a great script. Have adapted it successfully to my site. Had a bit of trouble with the login script but that was my inexperience with php/sql
For those struggling with it here's how I achieved the login ...
activated != "Activated")) {
header ('Location: /account_not_activated.php');
exit;
}
}
?>
May 3rd, 2009 at 11:07 am
oops! how do I get code up in a message??
November 24th, 2009 at 9:39 am
Has anyone done a tut on adding info/action images in a registration form? When they hover over the image a box opens and gives more information on that part of the form.
December 7th, 2009 at 12:18 pm
great..!
thank's
December 16th, 2009 at 4:54 am
Excellent Tutorial. The most admiring part of this tutorial is the manner in which it has been explained. Very well explained. KEEP IT UP !!!
Your website design is also cool.
December 28th, 2009 at 7:33 am
Great post thank you for sharing with us.
February 8th, 2010 at 12:54 pm
Assembled, fixed the "provide valid e-mail" bug (for anybody who doesn't know - its the exclamation mark before eregi), but mail didn't came.
Is somewhere script similar to this which actually WORKS?
February 21st, 2010 at 7:25 am
can u send me the code for a page which includes the login and registration forms in a single page.I am awaiting for your reply... i hope ypu reply soon.. please... get it for me...
March 8th, 2010 at 3:31 pm
This is fantastic, and helped me greatly, thanks for the easy to follow and informative tutorial. I'm a little unsure about how the activation of the account works as I can login following registration without clicking on the email activation link. I'm sure I'm missing something simple, but don't know if it's something i need to include in my login script or if it should be covered in the scripts here. Any thoughts you have for a noob like me would be awesome.
Cheers,
March 9th, 2010 at 8:35 pm
You should put all this into a little zip file with everything in it.