..
1. Database and configuration files
Many sites, for example, through the link directory, chat or discussion forums, in order to use certain services that users need to enroll using your email and possibly also choosing a user ID and password for 'authentication.
The passsword is easily forgotten, so it's good to also provide visitors the opportunity to recover their password and receive it in the mailbox reported in enrollment.
In this short article will show some of the steps common for this type of service:
The database that utilizzaremo, we might call "members" will have a very simple structure and contains a single table that will be associated with 4 fields:
CREATE TABLE `subscriptions` (
`Id` int (5) NOT NULL auto_increment,
`Email` varchar (50) NOT NULL default'',
`Password` varchar (10) NOT NULL default'',
`Active` enum ('0 ', '1') NOT NULL default '0 ',
PRIMARY KEY (`id`)
);
At this point, our application can be structured in this way:
<Php
/ / Class connection to the DBMS and database selection
MySQL class
{
MySQL function ()
{
/ / Connection parameters
$ This-> host_name = "localhost";
$ This-> user_name = "username";
$ This-> password = "password";
$ This-> data_name = "members";
$ This-> link = @ mysql_connect ($ this-> host_name, $ this-> user_name, $ this-> password) or die (mysql_error ());
@ Mysql_select_db ($ this-> data_name) or die (mysql_error ());
}
}
/ / Instance of the class
$ Date = new MySQL ();
/ / Mail administrator
$ Admin_email = "info@miosito.it";
?>
It contains a class that deals with the connection to the MySQL database and selection, on the same page that contains the code necessary to the instance of the class as well as the email address that will be the sender of all email messages sent by the system.
| |
Linux (Course)
Complete guide to open-source system. Starting from 49 €. |
| |
MySQL (Course)
Management of open-source database. Starting from 39 €. |
| |
PHP (Course)
Full course for creating dynamic Web sites. Starting from 49 €. |