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.
\
Tuesday, June 15, 2010
php login
Tutorial:
http://www.phpeasystep.com/workshopview.php?id=6
1. Create your database. It can be created by yourself or through the register.php.
2. Post the login html.
================
form name="form1" method="post" action="checklogin.php"
================
actually calls the checklogin.php when the user click the submit button.
3. create the checklogin.php, which is the main php access to the database the check username and password.
4. Create the login_success.php, which leads to the page if the login is right.
The most important part of the success.php is
================
session_start();
================
It creates a session for php to process. The session is different than regular cookies. Cookies are saved on users computer, which other user might access and change the login session. A php session, on the other hand, saves the data on the server, much safer to the users.
5. Create the logout.php, which destroys the session.
http://www.phpeasystep.com/workshopview.php?id=6
1. Create your database. It can be created by yourself or through the register.php.
2. Post the login html.
================
form name="form1" method="post" action="checklogin.php"
================
actually calls the checklogin.php when the user click the submit button.
3. create the checklogin.php, which is the main php access to the database the check username and password.
4. Create the login_success.php, which leads to the page if the login is right.
The most important part of the success.php is
================
session_start();
================
It creates a session for php to process. The session is different than regular cookies. Cookies are saved on users computer, which other user might access and change the login session. A php session, on the other hand, saves the data on the server, much safer to the users.
5. Create the logout.php, which destroys the session.
Database related
Good mysql tutorial.
http://www.webdevelopersnotes.com/tutorials/sql/mysql_training_course_creating_tables.php3
Create database on the linux system:
================
mysql -u root -p
create database employees;
GRANT ALL ON employees.* TO setup@localhost;
================
First line login as root.
Second line create an database.
Third line give the user "setup" all the privilege.
===============
show databases;
use employees;
show tables;
CREATE TABLE `members` (
`id` int(4) NOT NULL auto_increment,
`username` varchar(65) NOT NULL default '',
`password` varchar(65) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=2 ;
INSERT INTO `members` VALUES (1, 'john', '1234');
describe members;
select * from members;
===============
0 line shows the database you can operate.
First line select a database to operate.
Second line create a table.
Third line insert one data into the tabel.
4th and 5th line check the table and database.
\
http://www.webdevelopersnotes.com/tutorials/sql/mysql_training_course_creating_tables.php3
Create database on the linux system:
================
mysql -u root -p
create database employees;
GRANT ALL ON employees.* TO setup@localhost;
================
First line login as root.
Second line create an database.
Third line give the user "setup" all the privilege.
===============
show databases;
use employees;
show tables;
CREATE TABLE `members` (
`id` int(4) NOT NULL auto_increment,
`username` varchar(65) NOT NULL default '',
`password` varchar(65) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=2 ;
INSERT INTO `members` VALUES (1, 'john', '1234');
describe members;
select * from members;
===============
0 line shows the database you can operate.
First line select a database to operate.
Second line create a table.
Third line insert one data into the tabel.
4th and 5th line check the table and database.
\
php upload
The next step is to allow a user to upload a file, through php. Here is a nice tutorial about that.
http://www.tizag.com/phpT/fileupload.php
http://www.tizag.com/phpT/fileupload.php
flv streaming
Apache is not good at video stream. The www server for video streaming is lighttpd. It works with php and mysql too.
After you installed lighttpd, put the following line in the conf file
=============
server.modules = (
"mod_access",
"mod_alias",
"mod_accesslog",
"mod_compress",
"mod_fastcgi",
"mod_rewrite",
"mod_auth",
"mod_flv_streaming",
"mod_expire",
"mod_secdownload"
)
flv-streaming.extensions = ( ".flv" )
fastcgi.server = ( ".php" => ((
"bin-path" = "/usr/bin/php-cgi",
"socket" = "/tmp/php.socket"
)))
============
You will need php-cgi and other software.
===========
sudo apt-get install php-cig ffmepg
===========
A webpage is needed to display the player. You can use the some html code into it, which can be found http://www.topfstedt.de/weblog/?page_id=208
In the player has to be at the server side. It's your own choice for the player. I am using FLVScrubber.swf. Later, you can make your own player. You need put the play in the same directory as the html.
After you installed lighttpd, put the following line in the conf file
=============
server.modules = (
"mod_access",
"mod_alias",
"mod_accesslog",
"mod_compress",
"mod_fastcgi",
"mod_rewrite",
"mod_auth",
"mod_flv_streaming",
"mod_expire",
"mod_secdownload"
)
flv-streaming.extensions = ( ".flv" )
fastcgi.server = ( ".php" => ((
"bin-path" = "/usr/bin/php-cgi",
"socket" = "/tmp/php.socket"
)))
============
You will need php-cgi and other software.
===========
sudo apt-get install php-cig ffmepg
===========
A webpage is needed to display the player. You can use the some html code into it, which can be found http://www.topfstedt.de/weblog/?page_id=208
In the player has to be at the server side. It's your own choice for the player. I am using FLVScrubber.swf. Later, you can make your own player. You need put the play in the same directory as the html.
Subscribe to:
Posts (Atom)