Download as pdf or txt
Download as pdf or txt
You are on page 1of 23

ASSIGNMENT 2

SUBJECT CODE : CS02414


SUBJECT NAME : Internet Programming – 5G
SEM / YEAR : IV / 2ND
TITLE : Student Chat Box
NAME : P. Muzakir
REG NO : 191711306

GRADING RUBRICS
S.No Components Marks Marks Remarks
(100) scored
Implementation 90
1.
1) Language used (5)
2) Number of classes (5)
3) Number of functions (5)
4) Data Structures used (5)
5) Variable declaration (5)
6) Number of nested for loops used (5)
7) Database connectivity (5)
8) New mode of Input/output (5)
(Hardware devices) (5)
9) Programming Alignment or style (5)
10) Coupling (5)
11) Cohesion (5)
12) Time Complexity (5)
13) Space complexity (5)
14) Snapshots (10)
15) Results (10)
2. Conclusion 5
3. References 5
Total 100
IMPLEMENTATION
LANGUAGES USED
 HTML
 PHP
 CSS
 JAVA SCRIPT

 HTML provides the basic structure of sites which is enhanced and modified by other
technologies like CSS and JavaScript

 JavaScript is used to control the behavior of different of different elements.

 CSS is used to control presentation, formatting and layout.

NUMBER OF CLASSES
In this project the classes used are seven. They are listed below
1. Bootstrap
2. Custom
3. Jquery
4. Jquery.parallax
5. Nivo_lightbox.min
6. Smooth scroll
7. Wow.min

NUMBER OF FUNCTIONS
There are eight functions used in this system. They are listed below
1. Number()
2. String()
3. Escape()
4. isFinite()
5. Eval()
6. parseInt()
7. isNaN()
8. EcodeURI()

The function statement declares a function.A declared function is "saved for later use", and will
be executed later, when it is invoked. In javaScript, functions are objects, and they have both
properties and methods.A function can also be defined using an expression.

DATA STRUCTURES USED

 A data structure is a specialized format for organizing and storing data. General data
structure types include the array, the file, the record, the table, the tree, and so on. Any data
structure is designed to organize data to suit a specific purpose so that it can be accessed
and worked with in appropriate ways. In computer programming, a data structure may be
selected or designed to store data for the purpose of working on it with various algorithms.
 Here no data structures are being used because the project is mainly dependent on front
end HTML, CSS and java script.
 It refers to the methods of organizing units of data within larger data sets. Achieving and
maintaining specific data structures help improve data access and value. Data structures
also help programmers implement various programming tasks.

VARIABLE DECLARATION

 Variable means anything that can vary. JavaScript includes variables which hold the data
value and it can be changed anytime.JavaScript uses reserved keyword var to declare a
variable. A variable must have a unique name. You can assign a value to a variable using
equal to (=) operator when you declare it or before using it.
 Defining data and then manipulating that data has always been the basis of programming.
What is programming without data? I assume you guessed "nothing." Data types are
basically either Variables or Constants.
 Defining data and then manipulating that data has always been the basis of programming.
What is programming without data? I assume you guessed "nothing." Data types are
basically either Variables or Constants.

The scope of a variable is the region of your program in which it is defined. JavaScript variables
have only two scopes.

GLOBAL VARIABLES

A global variable has global scope which means it can be defined anywhere in your JavaScript
code.

LOCAL VARIABLES

A local variable will be visible only within a function where it is defined. Function parameters are
always local to that function.

Within the body of a function, a local variable takes precedence over a global variable with the
same name. If you declare a local variable or function parameter with the same name as a global
variable, you effectively hide the global variable.

var arr = [ [1,2], [3,4], [5,6]];for (var i=0; i < arr.length; i++) {console.log(arr[i]);}

var arr = [ [1,2], [3,4], [5,6]];

for (var i=0; i < arr.length; i++) {

for (var j=0; j < arr[i].length; j++) {

console.log(arr[i]); }}
DATABASE CONNECTIVITY

 In this project PHP is used as backend database connectivity


 A Database connection is facility in computer science that allows client software to talk to
database server software, whether on the same machine or not.A connection is required to
send commands and receive answers, usually in the form of a result set.
 Connections are a key concept in data-centric programming. Since some DBMS engines
require considerable time to connect connection pooling was invented to improve
performance. No command can be performed against a database without an "open and
available" connection to it.
 Connections are built by supplying an underlying driver or provider with a connection
string, which is a way of addressing a specific database or server and instance as well as
user authentication credentials
 Once a connection has been built it can be opened and closed at will, and properties can be
set. The Connection String is composed of a set of key/value pairs as dictated by the data
access interface and data provider being used.
 Many databases only allow one operation to be performed at a time on each connection. If
a request for data is sent to the database and a result set is returned, the connection is open
but not available for other operations until the client finishes consuming the result set.
Other databases, like SQL Server 2005, do not impose this limitation. However, databases
that provide multiple operations per connection usually incur far more overhead than those
that permit only a single operation task at a time.

NEW MODE OF INPUT/OUTPUT (HARDWARE DEVICES)

1. Input device (or input unit)

2. CPU (Central Processing Unit)

3. Memory (or Memory unit)

4. Output device (Output unit)


INPUT UNIT

▪ Keyboard

▪ Mouse

▪ Flash drive

▪ Scanners

▪ Joysticks

OUTPUT UNIT :

▪ Monitor

▪ Printer

▪ Speaker

▪ Monitor
▪ Sound card

CODING

Index.php

<?php

session_start();

if(!isset($_SESSION['username'])) {

?>

<form name="form2" action="login.php" method="post">

<table border="1" align="center">

<tr>
<td>Username: </td>

<td><input type="text" name="username"></td>

</tr>

<tr>

<td>Password: </td>

<td><input type="password" name="password"></td>

</tr>

<tr>

<td colspan="2"><input type="submit" name="submit" value="Login"></td>

</tr>

<tr>

<td colspan="2"><a href="register.php">Register here to get an account</a></td>

</tr>

</table>

</form>

<?php

exit;

?>

<html>

<head>

<title>Chat Box</title>

<script
src="http://code.jquery.com/jquery-2.2.4.min.js"

integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="

crossorigin="anonymous"></script>

<script>

function submitChat() {

if(form1.msg.value == '') {

alert("Enter your message!!!");

return;

var msg = form1.msg.value;

var xmlhttp = new XMLHttpRequest();

xmlhttp.onreadystatechange = function() {

if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {

document.getElementById('chatlogs').innerHTML = xmlhttp.responseText;

xmlhttp.open('GET','insert.php?msg='+msg,true);

xmlhttp.send();

$(document).ready(function(e){

$.ajaxSetup({

cache: false
});

setInterval( function(){ $('#chatlogs').load('logs.php'); }, 2000 );

});

</script>

</head>

<body>

<form name="form1">

Your Chatname: <b><?php echo $_SESSION['username']; ?></b> <br />

Your Message: <br />

<textarea name="msg"></textarea><br />

<a href="#" onclick="submitChat()">Send</a><br /><br />

<a href="logout.php">Logout</a><br /><br />

</form>

<div id="chatlogs">

LOADING CHATLOG...

</div>

</body>

Insert.php

<?php

session_start();

$uname = $_SESSION['username'];

$msg = $_REQUEST['msg'];
$con = mysql_connect('localhost','root','');

mysql_select_db('chatbox', $con);

mysql_query("INSERT INTO logs (`username`, `msg`) VALUES ('$uname', '$msg')");

$result1 = mysql_query("SELECT * FROM logs ORDER BY id DESC");

while($extract = mysql_fetch_array($result1)) {

echo "<span>" . $extract['username'] . "</span>: <span>" . $extract['msg'] . "</span><br />";

Login.php

<?php

session_start();

$username = $_POST['username'];

$password = $_POST['password'];

$con = mysql_connect('localhost', 'root', '');

mysql_select_db('chatbox', $con);

$result = mysql_query("SELECT * FROM users WHERE username='$username' AND


password='$password'");

if(mysql_num_rows($result)){

$res = mysql_fetch_array($result);

$_SESSION['username'] = $res['username'];

echo "You are now Logged in. Click <a href='index.php'>here</a> to go back to main chat
window.";

}
else{

echo "No user found. Please go <a href='index.php'>back</a> and enter the correct login.<br>";

echo "You may register a new account by clicking <a href='register.php'>here</a>.";

?>

Logout.php

<?php

session_start();

session_destroy();

echo "<center>";

echo "You have logged out. Click <a href='index.php'>here</a> to login again";

echo "</center>";

logs.php

<?php

$con = mysql_connect('localhost','root','');

mysql_select_db('chatbox', $con);

$result1 = mysql_query("SELECT * FROM logs ORDER BY id DESC");

while($extract = mysql_fetch_array($result1)) {

echo "<span>" . $extract['username'] . "</span>: <span>" . $extract['msg'] . "</span><br />";

}
Register.php

<?php

if(isset($_POST['submit'])) {

$con = mysql_connect('localhost', 'root', '');

mysql_select_db('chatbox', $con);

$uname = $_POST['username'];

$pword = $_POST['password'];

$pword2 = $_POST['password2'];

if($pword != $pword2) {

echo "Passwords do not match. <br>";

else {

$checkexist = mysql_query("SELECT username FROM users WHERE username = '$uname'");

if(mysql_num_rows($checkexist)){

echo "Username already exists, Please select other username.<br>";

else {

mysql_query("INSERT INTO users (`username`,`password`) VALUES('$uname','$pword')" );

echo "You are now registered. Click <a href='index.php'>here</a> to start chatting";

?>
<html>

<head>

<title></title>

</head>

<body>

<form name="form1" action="register.php" method="post">

<table border="1" align="center">

<tr>

<td>Enter your Username: </td>

<td><input type="text" name="username"></td>

</tr>

<tr>

<td>Enter your Password: </td>

<td><input type="password" name="password"></td>

</tr>

<tr>

<td>Repeat your Password: </td>

<td><input type="password" name="password2"></td>

</tr>

<tr>

<td colspan="2"><input type="submit" name="submit" value="Register"></td>

</tr>

</table>
</form>

<body>

</html>

Sql text file

-- phpMyAdmin SQL Dump

-- version 4.5.2

-- http://www.phpmyadmin.net

--

-- Host: localhost

-- Generation Time: Aug 11, 2017 at 12:18 PM

-- Server version: 10.1.13-MariaDB

-- PHP Version: 5.6.23

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";

SET time_zone = "+00:00";

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;

/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS


*/;

/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;

/*!40101 SET NAMES utf8mb4 */;

--

-- Database: `chatbox`

--
-- --------------------------------------------------------

--

-- Table structure for table `users`

--

CREATE TABLE `users` (

`id` int(11) NOT NULL,

`username` varchar(255) NOT NULL,

`password` varchar(255) NOT NULL

) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--

-- Indexes for dumped tables

--

--

-- Indexes for table `users`

--

ALTER TABLE `users`

ADD PRIMARY KEY (`id`);

--

-- AUTO_INCREMENT for dumped tables

--

--

-- AUTO_INCREMENT for table `users`

--
ALTER TABLE `users`

MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;

/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;

/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

COUPLING

Coupling is a measure that defines the level of inter-dependability among modules of a program.
It tells at what level the modules interfere and interact with each other. The lower the coupling,
the better the program.

There are five levels of coupling, namely -

 Content coupling - When a module can directly access or modify or refer to the content
of another module, it is called content level coupling.
 Common coupling- When multiple modules have read and write access to some global
data, it is called common or global coupling.
 Control coupling- Two modules are called control-coupled if one of them decides the
function of the other module or changes its flow of execution.
 Stamp coupling- When multiple modules share common data structure and work on
different part of it, it is called stamp coupling.
 Data coupling- Data coupling is when two modules interact with each other by means of
passing data (as parameter). If a module passes data structure as parameter, then the
receiving module should use all its components.

COHESION
Cohesion is a measure that defines the degree of intra-dependability within elements of a module.
The greater the cohesion, the better is the program design.
There are seven types of cohesion, namely –

 Co-incidental cohesion - It is unplanned and random cohesion, which might be the result
of breaking the program into smaller modules for the sake of modularization. Because it
is unplanned, it may serve confusion to the programmers and is generally not-accepted.
 Logical cohesion - When logically categorized elements are put together into a module,
it is called logical cohesion.
 Temporal Cohesion - When elements of module are organized such that they are
processed at a similar point in time, it is called temporal cohesion.
 Procedural cohesion - When elements of module are grouped together, which are
executed sequentially in order to perform a task, it is called procedural cohesion.
 Communicational cohesion - When elements of module are grouped together, which are
executed sequentially and work on same data (information), it is called communicational
cohesion.
 Sequential cohesion - When elements of module are grouped because the output of one
element serves as input to another and so on, it is called sequential cohesion.
 Functional cohesion - It is considered to be the highest degree of cohesion, and it is
highly expected. Elements of module in functional cohesion are grouped because they all
contribute to a single well-defined function. It can also be reused.

TIME COMPLEXITY

Time complexity is simply a measure of the time it takes for a function or expression to complete
its task, as well as the name of the process to measure that time. It can be applied to almost any
algorithm or function but is more useful for recursive functions. There is little point in measuring
time complexity for applications such as fetching the username and password from a database for
comparison or simply saving data whether it is 20 ms or 5 ms; that would be more in the line of
access time. It has nothing to do with caring about its execution time, but rather that the difference
is negligible. However, if there is a recursive function that may be called multiple times,
determining and understanding the source of its time complexity may help shorten the overall
processing time from, say, 600 ms to 100 ms.
Time complexity is expressed typically in the "big O notation," but there are other notations. This
is a mathematical representation of the upper limit of the scaling factor for an algorithm and is
written as O(Nn), with "N" being the number of inputs and "n" being the number of looping
expressions.
BIG O COMPLEXITY

SPACE COMPLEXITY

The term Space Complexity is misused for Auxiliary Space at many places. Following are the
correct definitions of Auxiliary Space and Space Complexity.

Auxiliary Space is the extra space or temporary space used by an algorithm.

Space Complexity of an algorithm is total space taken by the algorithm with respect to the input
size. Space complexity includes both Auxiliary space and space used by input.

For example, if we want to compare standard sorting algorithms on the basis of space, then
Auxiliary Space would be a better criteria than Space Complexity. Merge Sort uses O(n) auxiliary
space, Insertion sort and Heap Sort use O(1) auxiliary space. Space complexity of all these sorting
algorithms is O(n) though.
SNAP SHOTS

LOGIN FORM
CHATBOX

RESULT

The Student Chat Box using HTML is implemented and executed successfully.
CONCLUSION

The main objective of the project is to develop a Secure Chat Application. I had taken a wide range
of literature review in order to achieve all the tasks, where I came to know about some of the
products that are existing in the market. I made a detailed research in that path to cover the loop
holes that existing systems are facing and to eradicate them in our application. Using this system
we can chat with teachers and among the students and can solve the doubts.

REFERENCES
1. Mayur Jain,” Smart Home System Using Android Mobile Devices”, Journal of Computing
Technologies Vol 2, Issue 3 ISSN 2278 – 3814.

2. IEEE std. 802.15.4 - 2003: “Wireless Medium Access Control (MAC) and Physical Layer
(PHY) specifications for Low Rate Wireless Personal Area Networks (LRWPANs)”

3. KiumiAkingbehin,Akinsola Akingbehin.,“Alternativ es for Short Range Low PowerWireless


Communications,” IEEE.2005: 94 – 95

4. A.R.Al-Ali and M. AL-Rousan. “Java-Based Home Automation System”. IEEE Transaction on


Consumer Electronics, Vol.50, No. 2, May 2004.

5. N. Sriskanthan and Tan Karand. “Bluetooth Based Home Automation System”. Journal of
Microprocessors and Microsystems, Vol. 26, pp.281-289, 2002.

6. Y.R.Dhumal,” Green House Automation using Zig bee and Smart Phone”, International Journal
of Advanced Research in Computer Science and Software Engineering Research Paper, Volume
3, Issue 5, May 2013
7. Soyoung Hwang and Donghui Yu,” Remote Monitoring and Controlling System Based on Zig
Bee Networks”, International Journal of Software Engineering and Its Applications Vol. 6, No. 3,
July, 2012

8. Sweatha K N,” ADVANCE HOME AUTOMATION USING FPGA CONTROLLER,


International Journal of Advanced Research in Computer and Communication Engineering Vol.
2, Issue 7, July 2013.

9. Asim S,Daniel.S.Junichi.F and Neema M,”Sensay:A context-aware mobile phone,”


Proceedings,seventh IEEE International symposium on Wearable computers,pp.248249,2003.

10. Fan Jiang and Saoping Ku,”How to display the data from database by Listview on Android,”
second International workshop on Intelligent Systems and Applications(ISA),2010.

You might also like