1. After you have unzipped the archive "register_login_script_users_online.zip", open the "config.php" file (in the "usrincls/" folder) and change the following data for connecting to MySQL database, with your data.
- $mysql['host'] = "localhost"; - instead of localhost add your MySQL server address.
- $mysql['user'] = "userdb"; - instead of userdb write your username for database.
- $mysql['pass'] = "passdb"; - instead of passdb write your password for database
- $mysql['bdname'] = "dbname"; - instead of dbname add the name of your database.
- The following codes are for the Administrator data:
// Set administrator login data, and e-mail
define('ADMINNAME', 'admin'); // the admin name (at least 3 characters)
define('ADMINPASS', 'pass123'); // the admin password (at least 7 characters)
define('ADMINMAIL', '[email protected]'); // Here add the Administrator e-mail
- The sender email address which appears in registration confirmation message or in the email for recovery password, is the Admin's e-mail added in the constant "ADMINMAIL (here "[email protected]").
- If the server of your website can't use mail() function to send emails with link to confirm registration, or recovery user's data, and notification when new message are added; the script has implemented the PHPMailer class to send the mails via GMail.
So, if you want the script to send the mails via GMail, and you have a GMail account, set the value of USEGMAIL constant to 1, and add your GMail Username and Password to GMAILUSER, and GMAILPASS, to the following code in "config.php":
// If you want to use a GMail account for sending mails to user (Link confirmation, Recovery data)
// set USEGMAIL to 1, and add your GMail Username and Password to GMAILUSER, and GMAILPASS
define('USEGMAIL', 0);
define('GMAILUSER', '[email protected]');
define('GMAILPASS', 'gmailpass');
- Settings for log in with Facebook, Yahoo, Google
- To add the "Button for Login with Facebook"
First you need a Developer APP ID, and Secret Key, from this page: https://developers.facebook.com/apps/ (after you login in facebook)
Click "Register as a developer", then you need to confirm your phone number.
For more details, see the documentation: Facebook Login for Server-side Apps
Then, in "config.php" set the value of FBCONN constant to 1, and add your FaceBook ID Developer (APP ID) to FBID, and the Secret Key (APP Secret) to FBSK .
// If you want to add Connect with FaceBook,
// Set FBCONN to 1, and add your FaceBook ID Developer (APP ID), and the secret key (APP Secret)
define('FBCONN', 1);
if(FBCONN == 0) {
define('FBID', 'YOUR_APP_ID');
define('FBSK', 'YOUR_APP_SECRET');
}
- By default, the script include "Button for Login with Yahoo". If you want to remove it, set the value of YHCONN constant to 0 (in "config.php").
// Value of 1 include button Connect with Yahoo, 0 removes it
define('YHCONN', 0);
- By default, the script include "Button for Login with Google". If you want to remove it, set the value of GOCONN constant to 0 (in "config.php").
// Value of 1 include button Connect with Google, 0 removes it
define('GOCONN', 0);
If you get "Forbide, 403 error" in redirected page from Yahoo or Google login, the problem is from a configuration in Apache server, mod_security is set up to block URLs in querystrings. In this case, contact server administrator to remove the blocking of URLs in querystrings.
- The following lines of code set options for user account
// if RANK is 0, the script will send a link to the user's e-mail, to confirm the registration
// if RANK > 0, the user can log in immediately after registration
define('RANK', 0);
define('ACCOUNT', 1); // If the value is different from 1, allow to create multiple accounts with same IP
define('ALLOWIMG', 1); // allows upload images in message (1), not allow (0)
define('ALLOWMAIL', 1); // allows mail notification when new message (1), not allow (0)
define('ROWSPAGE', 12); // numbers of messages displayed in the page
// HERE you cand edit the permissions for the image uploded by User
$imguprule = array(
'dir' => 'usrimgup/', // directory to store uploded images
'allowext' => array('gif', 'jpg', 'jpe', 'png'), // allowed extensions
'maxsize' => 200, // maximum allowed size for the image file, in KiloBytes
'width' => 800, // maximum allowed width, in pixeli
'height' => 600 // maximum allowed height, in pixeli
);
- If you want the user to confirm the registration to his e-mail address, let the value '0' at the constant RANK, so, after registration, a message will be sent to his e-mail with a link through which the user can confirm the registration. He can log in only after confirmation.
- If you want to remove the requirement of registration confirmation, replace the '0' with '1' (or other positive number) at the constant: RANK
- The elements of the Array variable: $imguprule define the allowed values for the image that can be uploaded by user in his page, and in message (directory name in which the images are saved ["usersimg"], allowed file extension, maximum size in kilobytes and the maximum dimensions allowed).
2. After you have added and saved your data for MySQL connection, copy on your server the "users.php" file (the "test.php" file can be used for test), and the directories: "icos", "usrimgup", "usrincls", "usrjs", and "usrtempl" (with all their content, in the same directory in which the file you want to include the script is).
3. Set to the directory "usrimgup", and to the file "ltmsgs_reset.txt" (in the folder "usrimgup/"), read-write-execute permissions for PHP (by setting CHMOD 0777 (or 0755) with your FTP application).
- The "usrimgup/" directory stores the images uploaded by the user, and the "ltmsgs_reset.txt" file stores the last reset date of the checking messages by Admin.
When the Admin logs in, in the user page, under messages appears a link "Latest Messages Posted to all Users". After you click on this link, will open the file "latestmsgs.php". This file will show all the messages added in all the user pages from the last reset. To reset the time of the last checking, you must add the admin password in the text box at the bottom of the page "latestmsgs.php", then click "Reset" button.
4. Access in your browser the file "create_tables.php" (in "usrincls/" folder) to create the tables in your database
(fo example, access in your browser - http://domain/usrincls/create_tables.php ).
If the tables are successfully created, you'll see a confirmation text.
5. Then add the following codes in the PHP file in which you want to use this script:
- At the beginning of the PHP file add the following code:
<?php include('users.php'); ?>
- In that file, where you want to appear the login form, add the following code:
<?php echo $login; ?>
- In the place you want to appear the Total number of users, Newest user, and Online users, add:
<?php
echo $objUsers->users['total'];
echo $objUsers->users['last'];
echo $objUsers->users['online'];
?>
- You can see how this code is added in the file "test.php".
- If you want to use the script in other language, just translate the texts in the file "texts.php" (in "usrincls/" directory).
- To change the number of paginated rows with users displayed in the page with all registered users, modify in "allusers.php" (in "usrtempl/" directory), at line 5, the value of the following variable:
$objUsers->rowsperpage = 30; // number of users paginated in the page with all users
- To change the logo image, modify the image in "logo.gif", in "icos" folder.