Tuesday, June 15, 2010

php registering.

The php registering page follows the tutorial:
http://www.knowledgesutra.com/forums/topic/7887-php-simple-login-tutorial/

There are a few things you want to pay attention to:

1. Each php file can use the line
===========
include ("dbConfig.php");
===========
which use the same database configuration, such as username, password, database name stuff.

2. In the registering php, there are 3 sections: op=reg, op=thanks, and "else". When a user open the php, there is no op value. The php will lead to "else" section directly, which actually put together a fill-in form. The line
===========
form action=\"?op=reg\"
===========
Actually reload the page into the first section op=reg.

3. The first section of the php op=reg checks the user fill-in information first. If there is an empty field, it display an error page. The user then have to use the back button to re-enter the information.

4. The real important part of the php code is:
===========
$q = "INSERT INTO `members` (`username`,`password`) "
."VALUES ('".$_POST["username"]."', "."'".$_POST["password"]."')";
===========
which use the command "insert into 'members' ('useranems','password') values('xx','xx').


5.
===========
$r=mysql_query($q)
===========
will push the above command to the mysql database.

\

No comments:

Post a Comment