Qondio
Front
Intel
IntelMart
Shares
My Qondio
Account
edu2004eu > Intel > Creating a small registration script in PHP and MySQL

qondio.com/vQoh PRINT EMAIL

Creating a small registration script in PHP and MySQL

This tutorial will show you how to add a user to a MySQL users database using PHP.

You will need only one file for this (assuming you already have a web server, PHP and MySQL installed and working).

Create a new database named tempdb (if you don't know how, see http://phpmyadmin.net/). Inside the database create a table named users with 3 columns:
`id`, INT(11), auto_increase, primary
`username` VARCHAR(50)
`password` VARCHAR(50)

Now let's create the PHP file. Go to your web root folder and create a file called register.php
Open it with your favorite text editor and type the following:

<?php
if($_POST)
if( && $_POST['user'] && $_POST['pass']){
$conn=mysql_connect("localhost","root","MYSQLPASSWORD"); //replace MYSQLPASSWORD with you MySQL password
$sql="INSERT INTO users VALUES (NULL,'$_POST[user]','$_POST[pass]')";
$sql2=mysql_query($sql) or die(mysql_error());
}
else echo "you didn't supply both, username and password";
else
echo "<form action=\"$_SERVER[PHP_SELF]\" method=post>User: <input type=text name=user><br>Pass: <input type=password name=pass><br><input type=submit></form>";
?>

That should be it. This is a simple tutorial which doesn't include checking if the user exists and so on. It may be that it also has some mistakes, don't hesitate to contact me if it does.

Contributed by edu2004eu on September 4, 2008, at 11:46 AM UTC.

Reactions

No reactions yet.

Rate This Intel

Please login or sign up to rate this intel.

Comments

Please login or sign up to add a comment.

Share

Copyright Notice

The copyright for this content entitled "Creating a small registration script in PHP and MySQL" has been specified by the contributor as:

All Rights Reserved

This content may not be copied, distributed or adapted by anyone under any circumstances.

Login Here with
Any Email Address
Any Password
No account? Sign up.

Intel Contributor
This intel was contributed by edu2004eu

Qondio Archive
May, 2012
123456
78910111213
14151617181920
21222324252627
28293031


2008
January, February, March, April, May, June, July, August, September, October, November, December
2009
January, February, March, April, May, June, July, August, September, October, November, December
2010
January, February, March, April, May, June, July, August, September, October, November, December
2011
January, February, March, April, May, June, July, August, September, October, November, December
2012
January, February, March, April, May

Sign Up
Not a member yet? Qondio is a powerful network for making it online. If you have a website to promote, we can help. Sign up and get in on the action.

About Qondio
Welcome to Qondio! Discover the awesome power this network can deliver by going to our About page. Or you could skip straight to the Sign Up form.

ABOUT
SUCCESS GUIDE
FEATURES
FAQ
ADVERTISE
CONTACT
USAGE POLICY
PRIVACY POLICY


TWITTER
FACEBOOK