Php-mysql Course

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.


The script is in two versions: Advanced, and Smiple.

Advanced Register /Login Users Script

The Advanced version uses PHP PDO to perform SQL queries, it has Admin functions.
• To Download it, click: Register / Login /Online Users Script

- To see how it looks the page of a user when a visitor visits it, click User page.
- To test the page of a user when he /she is logged in his /her personal page, click Logged user.
- To test the page of a user when Admin logs in, click Admin logged.

Simple Register /Login Users Script

• To Download it, click: Simple Register / Login /Online Users Script

- The Simple version uses PHP MySQLi to perform SQL queries. Not has Admin control, neither PHPMailer class.
- To see the page of a user when a visitor visits it, click User page.
- To test the page of a user when he /she is logged in his /her personal page, click Loged user.

Instructions about instalation, script structure (tables, files and their role) and other details can be found in the file "Read.html", in the ZIP archive that you can download from the link above (Register / Login /Online Users Script).

Security features


• How to display in your web page a content for visitors and another content for logged users:
- It can be made by checking the existence of the variable: $_SESSION['username'].
<?php
if(isset($_SESSION['username'])) {
  echo 'Execute some code for logged users';
}
else {
  echo 'Add another code for visitors';
}
?>

• How to display a content in your web page according to the user's rank.
- It can be made by checking the value of the variable: $_SESSION['rank'].
<?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';
}
?>

- This script is free (does not provide support or personal modifications).

It was successfully tested for a general configuration on localhost with XAMPP (Internet Explorer, Mozilla Firefox, and Opera), and also on the server of the website https://coursesweb.net. If on other systems does not work properly, depends on their configuration. Problems can appear especially on free hostings which have restrictions on the "session", or not support PDO (MySQLi for the version Simple).

Daily Test with Code Example

HTML
CSS
JavaScript
PHP-MySQL
Which HTML element can be used to embed a SWF flash content?
<object> <div> <script>
<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>
Which CSS pseudo-class adds a style to an input form field that has keyboard input focus?
:active :focus :hover
input:focus {
  background-color: #88fe88;
}
Click on the instruction which converts a JSON string into a JavaScript object.
JSON.stringify(javascript_object) object.toString() JSON.parse(json_string)
var jsnstr = '{"url": "http://coursesweb.net/", "title": "Web Development Courses"}';
var obj = JSON.parse(jsnstr);
alert(obj.url);
Indicate the PHP function which can be used to create or write a file on server.
fopen() file_put_contents() file_get_contents()
if (file_put_contents("file.txt", "content")) echo "The file was created";
else echo "The file can not be created";
Script Users Register, Login, Online

Last accessed pages

  1. Get and Modify content of an Iframe (32367)
  2. $_GET, $_POST and $_REQUEST Variables (33884)
  3. Ajax-PHP Chat Script (49508)
  4. JavaScript Course - Free lessons (31647)
  5. Volume and Surface Area Calculator for 3D objects (11276)

Popular pages this month

  1. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (310)
  2. The Mastery of Love (48)
  3. CSS cursor property - Custom Cursors (36)
  4. Read Excel file data in PHP - PhpExcelReader (35)
  5. PHP-MySQL free course, online tutorials PHP MySQL code (31)