This is a PHP script to Register and Login users in a website, and shows the Online users.
It has option to Log in with Facebook, Yahoo, or with a Google account.
It is created with the method based on classes and objects (OOP). Uses PHP, MySQL and Ajax / JavaScript (with jQuery) [it can work also in browsers with JavaScript disabled]. The connection to MySQL is made with PDO.
The HTML code is valid HTML5, also, works in Internet Explorer browsers which don't recognise HTML5 tags.
The Admin can delete users, modify their data, adds /delete messages and favorite links, and change their Rank, from -1 to 9 (the Rank -1 means banned, 0 is unconfirmed account, and a Rank 9 gives to the user Administration privileges).
The script can easily be used in other language, just translate the texts in a single file ("texts.php" in "usrincls/" directory).
The script includes button "Remember" that gives the posibility to automaticaly login the users in the next visits.
If the user forgot the password, the script can send it to his e-mail.
By default, this script is set to send a message to the user's e-mail, after the registration, with a link to confirm the registration, but this setting can easily be reset to let the user to log in imediately after registration, without any confirmation.
The script can send the emails via a local mail server (with PHP mail() function), or through SMTP via an GMail account, with the PHPMailer class.
Each user has a personal page that contains: an image uploaded by the user, the registration date, the last visit date, the number of visits /logins, and other personal data (name, pronoun, birthday, personal website, occupation, hobby).
In his personal page, the user can receive messages added by other users (will be notified by email), and can add 12 favorite links.
The logged user can delete the messages in his page, can modify the password and the e-mail address used to registration, then he/she will receive an email with the new data.
The messages posted in the user's page are paginated, and can be included an image (displayed in full page when click on it), the text can be formated with Bold, Italic, Underline.
The user which writes the message can select the option to receive email notification when new message is added.
The script displays the total number of users, the last registered user and the Online users (updated with Ajax every 2 minutes) with link to their page.
The script contains a page that shows a list with all registered users, and users loged with Facebook, that are paginated and can be ordered by Name, Last Visit, Registration date, Visits number, and Rank.
<?php if(isset($_SESSION['username'])) { echo 'Execute some code for logged users'; } else { echo 'Add another code for visitors'; } ?>
<?php if(isset($_SESSION['rank']) && $_SESSION['rank']>2) { echo 'Content for users with rank greater than 2'; } else if(isset($_SESSION['rank']) && $_SESSION['rank']==2) { echo 'Another content, for users with rank 2'; } else if(isset($_SESSION['rank'])) { echo 'Code for logged users with rank 1'; } ?>
<object type="application/x-shockwave-flash" data="file.swf" width="500" height="250"> <param name="src" value="file.swf" /> Your browser not support SWF. </object>
input:focus { background-color: #88fe88; }
var jsnstr = '{"url": "http://coursesweb.net/", "title": "Web Development Courses"}'; var obj = JSON.parse(jsnstr); alert(obj.url);
if (file_put_contents("file.txt", "content")) echo "The file was created"; else echo "The file can not be created";