1/26/24

PROGRAMMING LANGUAGES HISTORY(1940's to Present)

 

The history of programming languages can be divided into several generations, each characterized by different features and paradigms:

First Generation (1940s-1950s): Machine Languages

Machine language is the lowest-level programming language understood by a computer. It is a set of instructions that directly controls the computer's hardware. Machine language is typically written in binary code, which consists of 1s and 0s.

Characteristics of Machine Language

Machine language is specific to a particular type of computer. This means that a program written in machine language for one type of computer cannot be run on a different type of computer.

Machine language is difficult to read and write. This is because it is written in binary code, which is not a natural language for humans.

Machine language is efficient. This is because it is directly executed by the computer's hardware.

Advantages of Machine Language

Machine language is the fastest programming language. This is because it is directly executed by the computer's hardware.

Machine language is the most efficient programming language. This is because it uses the least amount of memory and processing power.

Disadvantages of Machine Language

Machine language is difficult to read and write. This is because it is written in binary code, which is not a natural language for humans.

Machine language is specific to a particular type of computer. This means that a program written in machine language for one type of computer cannot be run on a different type of computer.

Examples of Machine Language

The following is an example of a machine language instruction:

```

01000000 01100011 01100101 01100101

```

This instruction tells the computer to add the contents of two registers together and store the result in a third register.

 Programming in machine language is tedious, error-prone, and difficult to modify.

Second Generation (1950s-1960s): Assembly Languages

Assembly language is a low-level programming language that provides a symbolic representation of the instructions that a computer's central processing unit (CPU) can understand. It is a step up from machine code, which is the binary language that computers actually execute, but still much closer to the hardware than high-level languages like C or Python.

Assembly language is typically used for tasks that require precise control over the hardware, such as operating system kernels, device drivers, and embedded systems programming. It can also be used to create games and other applications that need to be very efficient or run on very limited hardware.

Advantages of Assembly Language

Speed: Assembly language can produce very fast code because it is so close to the hardware. This makes it ideal for applications that need to be very efficient, such as operating systems and device drivers.

Size: Assembly language code is typically much smaller than code written in a high-level language. This is because assembly language instructions are very compact and there is no need for a compiler or interpreter to translate the code into machine code.

Control: Assembly language gives the programmer complete control over the hardware. This can be useful for tasks such as debugging, performance tuning, and writing device drivers.

Disadvantages of Assembly Language

Complexity: Assembly language is a very complex language to learn and use. This is because it is so close to the hardware and there are many different instructions to remember.

Portability: Assembly language code is not portable between different types of CPUs. This is because the instructions that are used in assembly language are specific to a particular CPU architecture.

Difficulty in Debugging: Assembly language code can be difficult to debug because it is not as easy to read and understand as code written in a high-level language.

Examples of Assembly Language

Here is a simple assembly language program that prints the message "Hello, world!" to the console:

```

.data

message: .asciz "Hello, world!"

.text

.global main

main:

    mov eax, 4

    mov ebx, 1

    mov ecx, message

    mov edx, 13

    int 0x80

```

This program uses the following assembly language instructions:

mov: This instruction moves data from one register to another.

eax: This register is used to store the function return value.

ebx: This register is used to store the first argument to a function.

ecx: This register is used to store the second argument to a function.

edx: This register is used to store the third argument to a function.

int: This instruction calls a function.

0x80: This is the system call number for the `write` system call.

When this program is executed, it will print the message "Hello, world!" to the console.

Assembly Language Today

Assembly language is still used today, but it is not as common as it once was. This is because high-level languages have become much more powerful and easier to use. However, assembly language is still useful for tasks that require precise control over the hardware or for writing code that needs to be very efficient or run on very limited hardware.

Examples

1. x86 Assembly Language:

   - MOV AX, BX: Move the contents of register BX into register AX.

   - ADD AX, CX: Add the contents of register CX to the contents of register AX.

   - SUB AX, DX: Subtract the contents of register DX from the contents of register AX.

   - JMP label: Jump to the instruction at the specified label.

   - CALL label: Call the subroutine at the specified label.

2. ARM Assembly Language:

   - MOV R0, R1: Move the contents of register R1 into register R0.

   - ADD R0, R1: Add the contents of register R1 to the contents of register R0.

   - SUB R0, R1: Subtract the contents of register R1 from the contents of register R0.

   - B label: Branch to the instruction at the specified label.

   - BL label: Branch and link to the subroutine at the specified label.

3. MIPS Assembly Language:

   - ADD $t0, $t1, $t2: Add the contents of registers $t1 and $t2 and store the result in register $t0.

   - SUB $t0, $t1, $t2: Subtract the contents of register $t2 from the contents of register $t1 and store the result in register $t0.

   - J label: Jump to the instruction at the specified label.

   - JAL label: Jump and link to the subroutine at the specified label.

4. PowerPC Assembly Language:

   - ADD R0, R1, R2: Add the contents of registers R1 and R2 and store the result in register R0.

   - SUB R0, R1, R2: Subtract the contents of register R2 from the contents of register R1 and store the result in register R0.

   - B label: Branch to the instruction at the specified label.

   - BL label: Branch and link to the subroutine at the specified label.

5. RISC-V Assembly Language:

   - ADD X0, X1, X2: Add the contents of registers X1 and X2 and store the result in register X0.

   - SUB X0, X1, X2: Subtract the contents of register X2 from the contents of register X1 and store the result in register X0.

   - J label: Jump to the instruction at the specified label.

   - JAL label: Jump and link to the subroutine at the specified label.

Third Generation (1960s-1970s): High-Level Languages

High-level programming languages are designed to be more user-friendly, easier to read, and more concise than low-level languages. They are closer to human language, allowing programmers to express their intent more naturally. HLLs also typically provide built-in functions and libraries that can be used to perform common tasks, making them easier to learn and use.

Advantages of High-Level Languages:

Ease of use: HLLs are generally easier to learn and use than low-level languages. This is because they are designed to be more user-friendly and intuitive.

Expressiveness: HLLs allow programmers to express their intent more naturally. This is because they are closer to human language and provide built-in functions and libraries that can be used to perform common tasks.

Portability: HLLs are typically more portable than low-level languages. This is because they are not tied to a specific hardware platform or operating system.

Maintainability: HLLs are typically easier to maintain than low-level languages. This is because they are more concise and easier to read.

Disadvantages of High-Level Languages:

Performance: HLLs are typically not as efficient as low-level languages. This is because they are interpreted or compiled into an intermediate code that must be executed by a virtual machine or compiler.

Security: HLLs are typically not as secure as low-level languages. This is because they are more complex and provide more opportunities for errors and vulnerabilities.

Cost: HLLs can be more expensive to develop and maintain than low-level languages. This is because they require more specialized tools and expertise.

Common High-Level Languages:

Some of the most popular high-level programming languages include:

* Python

* Java

* C++

* C#

* JavaScript

* PHP

* Ruby

* Swift

* Go

* Kotlin

Applications of High-Level Languages:

High-level languages are used to develop a wide variety of applications, including:

* Web applications

* Desktop applications

* Mobile applications

* Games

* Operating systems

* Embedded systems

* Scientific simulations

* Artificial intelligence

* Machine learning

Fourth Generation (1970s-1980s): Very High-Level Languages

Very high-level languages (VHLLs) are programming languages that are designed to be easy to use and understand, even for people who have no prior programming experience. They are often used for developing applications that are intended to be used by non-programmers, such as business applications, web applications, and mobile applications.

VHLLs typically have a number of features that make them easy to use, such as:

Simple syntax: VHLLs typically have a simple and straightforward syntax that is easy to learn and remember. This makes it easy for people with no prior programming experience to get started with VHLLs.

High-level constructs: VHLLs typically provide high-level constructs that allow developers to write code that is concise and easy to understand. This makes it easier to develop complex applications quickly and easily.

Built-in libraries: VHLLs typically come with a number of built-in libraries that provide common functions and objects. This makes it easy for developers to add features to their applications without having to write a lot of code from scratch.

Rapid application development (RAD) tools: VHLLs often come with RAD tools that allow developers to quickly and easily create user interfaces and other application components. This makes it possible to develop applications in a fraction of the time it would take using a traditional programming language.

Some of the most popular VHLLs include:

Visual Basic: Visual Basic is a VHLL that was developed by Microsoft. It is a popular choice for developing Windows applications.

Java: Java is a VHLL that was developed by Sun Microsystems. It is a popular choice for developing web applications and mobile applications.

Python: Python is a VHLL that was developed by Guido van Rossum. It is a popular choice for developing web applications, data science applications, and machine learning applications.

Ruby: Ruby is a VHLL that was developed by Yukihiro Matsumoto. It is a popular choice for developing web applications and scripting applications.

PHP: PHP is a VHLL that was developed by Rasmus Lerdorf. It is a popular choice for developing web applications.

VHLLs can be a good choice for developers who want to quickly and easily develop applications that are intended to be used by non-programmers. However, VHLLs can also be limiting for developers who need to develop more complex applications or applications that require high performance.

Fifth Generation (1980s-Present): Artificial Intelligence and Logic Programming

Artificial Intelligence (AI) and Logic Programming are closely related fields that have significantly contributed to the advancements in computer science and various domains. Here are some key aspects of their relationship:

1. Knowledge Representation:

Logic programming provides a formal framework for representing knowledge in AI. It uses logical rules and facts to represent the world and reason about it. This makes it well-suited for solving problems that require reasoning and decision-making.

2. Declarative Programming Paradigm:

Logic programming follows a declarative programming paradigm, where the programmer declares the facts and rules, and the system automatically derives the conclusions. This declarative approach simplifies the development of complex AI applications.

3. Symbolic Reasoning:

Logic programming is based on symbolic reasoning, which allows it to represent and manipulate symbolic information, such as concepts, propositions, and relationships. This enables AI systems to perform higher-level reasoning tasks.

4. Automated Reasoning:

Logic programming languages provide automated reasoning capabilities, such as theorem proving, model checking, and satisfiability solving. These capabilities allow AI systems to make inferences, draw conclusions, and verify the correctness of knowledge bases.

5. Natural Language Processing:

Logic programming has been successfully applied in natural language processing (NLP). It enables AI systems to understand the meaning of sentences, generate natural language text, and perform tasks like machine translation, text summarization, and question answering.

6. Expert Systems:

Logic programming has been instrumental in the development of expert systems. Expert systems are AI programs that emulate the knowledge and reasoning skills of human experts in a specific domain. They use logical rules to represent expert knowledge and provide advice or solutions to users.

 

7. Robotics:

Logic programming has found applications in robotics for knowledge representation, planning, and control. It enables robots to reason about their environment, make decisions, and execute actions to achieve their goals.

8. Prolog:

Prolog is a widely-used logic programming language. It is known for its declarative syntax, automated reasoning capabilities, and ease of prototyping. Prolog has been successfully employed in various AI applications, including natural language processing, expert systems, and game playing.

In summary, artificial intelligence and logic programming complement each other to enable the development of intelligent systems capable of reasoning, decision-making, and solving complex problems. Logic programming provides a formal framework for knowledge representation and automated reasoning, while AI provides the broader context and methodologies for building intelligent systems.

Modern Era (1990s-Present): Object-Oriented, Functional, and Scripting Languages

Object-Oriented Languages (OOP)

Characteristics:

    * Classes and objects

    * Encapsulation

    * Inheritance

    * Polymorphism

Examples:

    * Java

    * C++

    * Python

    * C#

    * Ruby

Advantages of OOP:

Modularity: OOP allows you to break down your program into smaller, more manageable components. This makes it easier to maintain and update your code.

Reusability: OOP allows you to reuse code across different programs. This can save you time and effort.

Extensibility: OOP makes it easy to extend your programs with new features. This is because you can simply add new classes and objects to your program.

Disadvantages of OOP:

Complexity: OOP can be a complex programming paradigm to learn. This is because it involves a number of concepts, such as classes, objects, and inheritance.

Performance: OOP can be less efficient than other programming paradigms, such as procedural programming. This is because OOP programs typically involve more overhead.

Functional Languages

Characteristics:

    * Functions

    * Immutability

    * Recursion

    * Pattern matching

Examples:

    * Haskell

    * Lisp

    * Scheme

    * Clojure

Advantages of Functional Programming:

Conciseness: Functional programming languages are often more concise than other programming languages. This is because they use a number of features, such as function composition and recursion, that can be used to write code in a more compact way.

Immutability: Functional programming languages are typically immutable, which means that variables cannot be changed once they have been assigned a value. This can make it easier to reason about your code and to prevent errors.

Parallelism: Functional programming languages are often well-suited for parallel programming. This is because they use a number of features, such as immutable data structures and recursion, that make it easy to write code that can be executed in parallel.

Disadvantages of Functional Programming:

Performance: Functional programming languages can be less efficient than other programming languages, such as imperative programming languages. This is because functional programming languages typically use a number of features, such as immutability and recursion, that can be expensive to implement.

Learning curve: Functional programming languages can have a steep learning curve. This is because they use a number of concepts, such as functions, immutability, and recursion, that are not familiar to programmers who are used to other programming paradigms.

Scripting Languages

Characteristics:

    * Interpreted

    * Dynamic typing

    * High-level syntax

    * Often used for automation and scripting tasks

Examples:

    * JavaScript

    * Python

    * Ruby

    * PHP

    * Perl

Advantages of Scripting Languages:

Ease of use: Scripting languages are typically easy to learn and use. This is because they have a high-level syntax and they are often interpreted, which means that you don't need to compile your code before you can run it.

Flexibility: Scripting languages are very flexible. This is because they are typically dynamically typed, which means that you don't need to declare the type of a variable before you use it.

Portability: Scripting languages are often portable, which means that you can run them on a variety of different platforms.

Disadvantages of Scripting Languages:

Performance: Scripting languages can be less efficient than other programming languages, such as compiled languages. This is because scripting languages are typically interpreted, which means that they are executed one line at a time.

Security: Scripting languages can be less secure than other programming languages. This is because they are often dynamically typed, which means that it is possible to introduce errors into your code that would not be caught by a compiler.The evolution of programming languages has been driven by the need for higher levels of abstraction, ease of use, and expressiveness. As technology advances and new paradigms emerge, the history of programming languages continues to unfold with the development of new and innovative languages that push the boundaries of what is possible in computing.

10/13/22

DATA WARE HOUSING AND DATA MINING - R20- III Year –I Semester - JNTUK

 Welcome to our channel madhavarao maganti Click  channel 

The Data Warehousing stage involves collecting data, organizing it, transforming it into a standard structure, optimizing it for analysis, and processing it.

The Data Mining stage involves analyzing data to discover unknown patterns, relationships, and insights.

UNIT WISE Importent Questions

click here Important Questions

click here Unitwise Questions with Answers

click here Objective type Questions

Problems Solutions of DWDM

click here Dwdm Problems Solutions

click here Apiori and FP growth Problems    

click here K-means Problem Solution

A database has four transactions. Let min_sup=60%  and min_conf=80%
TID                 Date                     Items bought
100                 10/15/2018         {K, A, B, D}
200                10/15/2018         {D, A, C, E, B}
300                 10/19/2018         {C, A, B, E}
400                 10/22/2018         {B, A, D}
i) Find all frequent items using Apriori & FP-growth,respectively. 
Compare the efficiency of the two meaning process.
ii)List all of the strong association rules.

click here apiori problem Solution 

DWDM Lab Manual

click here Lab manual

UNIT –I:

Data Warehousing and Online Analytical Processing: Data Warehouse: Basic concepts, Data Warehouse Modelling: Data Cube and OLAP, Data Warehouse Design and Usage, Data Warehouse Implementation, Introduction: Why and What is data mining, What kinds of data need to be mined and patterns can be mined, Which technologies are used, Which kinds of applications are targeted.

click here unit1 material

click here for  unit1 video

UNIT –II:

Data Pre-processing: An Overview, Data Cleaning, Data Integration, Data Reduction, Data Transformation and Data Discretization.

 click here for unit2 material

UNIT –III:

Classification: Basic Concepts, General Approach to solving a classification problem, Decision Tree Induction: Attribute Selection Measures, Tree Pruning, Scalability and Decision Tree Induction, Visual Mining for Decision Tree Induction.

click here  for unit3 material

UNIT –IV:

Association Analysis: Problem Definition, Frequent Item set Generation, Rule Generation: Confident Based Pruning, Rule Generation in Apriori Algorithm, Compact Representation of frequent item sets, FPGrowth Algorithm. 

click here for Unit4 material

UNIT –V

Cluster Analysis: Overview, Basics and Importance of Cluster Analysis, Clustering techniques, Different Types of Clusters; K-means: The Basic K-means Algorithm, K-means Additional Issues, Bi-secting K Means,

click here for unit5 material






10/7/22

Object Oriented Programming through JAVA - R19- IV Year –I Semester - JNTUK

 Click here for Assignment 1

Click here for Assignment 2

Click here for Mid Exam 1

Click here for Mid Exam 2

Click here for Unit wise Questions

UNIT-I: INTRODUCTION TO JAVA: Introduction to OOP, procedural programming language and object-oriented language, principles of OOP, applications of OOP, history of java, java features, JVM, program structure. Variables, primitive data types, identifiers, literals, operators, expressions, precedence rules and associativity, primitive type conversion and casting, and flow of control. 

Click here for material UNIT1

UNIT-II: OBJECTS AND CLASSES: Classes and objects, class declaration, creating objects, methods, constructors and constructor overloading, garbage collector, the importance of static keyword and examples, this keyword, arrays, command line arguments, nested classes. 

Click here for material UNIT2

UNIT-III: INHERITANCE: Inheritance, types of inheritance, super keyword, final keyword, overriding an abstract class. Interfaces, creating the packages, using packages, the importance of CLASSPATH and java.lang package. Exception handling, the importance of try, catch, throw, throws and finally block, user-defined exceptions, and Assertions.

Click here for material UNIT3

UNIT-IV: MULTITHREADING: Introduction, thread life cycle, creation of threads, thread priorities, thread synchronization, communication between threads. Reading data from files and writing data to files, random access files

Click here for material UNIT4

UNIT-V: APPLETS AND AWT CLASSES: Applet class, Applet structure, Applet life cycle, sample Applet programs. Event handling: event delegation model, sources of event, Event Listeners, adapter classes, inner classes. AWT: introduction, components and containers, buttons, Label, Checkbox, Radio Buttons, List Boxes, Choice Boxes, Container class, Layouts, Menu and Scrollbar.

Click here for material UNIT5

10/1/22

SOFTWARE TESTING METHODOLOGIES MATERIAL- R16 - III Year – II Semester

SOFTWARE TESTING METHODOLOGIES MATERIAL 

UNIT-I:

Introduction: Purpose of Testing, Dichotomies, Model for Testing, Consequences of Bugs,Taxonomy of Bugs. Flow graphs and Path testing: Basics Concepts of Path Testing, Predicates, Path Predicates and Achievable Paths, Path Sensitizing, Path Instrumentation, Application of Path Testing.

Click Here UNIT-1

Click Here Explanation

UNIT-II:

Transaction Flow Testing: Transaction Flows, Transaction Flow Testing Techniques.

 Dataflow testing: Basics of Dataflow Testing, Strategies in Dataflow Testing, Application of Dataflow Testing.

Click Here UNIT-2

UNIT-III:

Domain Testing: Domains and Paths, Nice & Ugly Domains, Domain testing, Domains and Interfaces Testing, Domain and Interface Testing, Domains and Testability.

Paths, Path products and Regular expressions: Path Products & Path Expression, Reduction Procedure, Applications, Regular Expressions & Flow Anomaly Detection.

Click Here UNIT-3

UNIT-IV:

Syntax Testing: Why, What and How, A Grammar for formats, Test Case Generation, Implementation and Application and Testability Tips.

Logic Based Testing: Overview, Decision Tables, Path Expressions, KV Charts, and Specifications.

Click Here UNIT-4

UNIT – V:

State, State Graphs and Transition Testing: State Graphs, Good & Bad State Graphs, State Testing, and Testability Tips.

Graph Matrices and Application:-Motivational overview, matrix of graph, relations, power of a matrix, node reduction algorithm.

Click Here UNIT-5

UNIT -VI:

Software Testing Tools: Introduction to Testing, Automated Testing, Concepts of Test Automation, Introduction to list of tools like Win runner, Load Runner, Jmeter, About Win Runner ,Using Win runner, Mapping the GUI, Recording Test, Working with Test, Enhancing Test, Checkpoints, Test Script Language, Putting it all together, Running and Debugging Tests, Analyzing Results, Batch Tests, Rapid Test Script Wizard.

Click Here UNIT-6

12/9/21

WEB TECHNOLOGIES LAB EXERCISE 20 to EXERCISE 25

 20. AIM: User Authentication:

Assume four users user1, user2, user3 and user4 having the passwords pwd1, pwd2, pwd3 and pwd4 respectively. Write a PHP for doing the following.

1.  Create a Cookie and add these four user ids and passwords to this Cookie.

2.   Read the user id and passwords entered in the Login form and authenticate with the values (user id and passwords) available in the cookies.

If he is a valid user (i.e., user-name and password match) you should welcome him by name (user-name) else you should display “You are not an authenticated user’’.



SOURCE CODE:

LOGIN.PHP:

<?php setcookie("uid1","user1");

setcookie("pwd1","pwd1");

setcookie("uid2","user2");

setcookie("pwd2","pwd2");

setcookie("uid3","user3");

setcookie("pwd3","pwd3");

setcookie("uid4","user4");

setcookie("pwd4","pwd4");

?>

<!DOCTYPE html>

<html>

<head>

<title>User Authentication</title>

</head>

<body>

<h1 align="center">LOGIN</h1>

<form action="Authentication.php" method="post">

<table align="center" cellspacing="10">

<tr>

<td><b>User ID</b></td>

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

</tr>

<tr>

<td><b>Password</b></td>

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

</tr>

<tr>

<td colspan="2" align="center">

<input type="submit" name="submit" value="SUBMIT"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<input type="reset" value="RESET">

</td>

</tr>

</table>

</form>

</body>

</html>

AUTHENTICATION.PHP:

<!DOCTYPE html>

<html>

<head>

<title> User Authentication </title>

</head>

<body>

<?php

if($_POST["uid"]==$_COOKIE["uid1"]&&$_POST["pwd"]==$_COOKIE["pwd1"])

{

echo "welcome ".$_POST["uid"];

}

else if ($_POST["uid"]==$_COOKIE["uid2"] &&

$_POST["pwd"]==$_COOKIE["pwd2"])

{

echo "Welcome ".$_POST["uid"];

}

else if($_POST["uid"]==$_COOKIE["uid3"]&& $_POST["pwd"]==$_COOKIE["pwd3"])

{

echo "Welcome" .$_POST["uid"];

}

else if($_POST["uid"]==$_COOKIE["uid4"]&& $_POST["pwd"]==$_COOKIE["pwd4"])

{

echo "Welcome" .$_POST["uid"];

}

else{

echo "You are not an authenticated user.";

}

?>

</body>

</html>

OUTPUT:





EXPERIMENT-21:

 AIM: Example PHP program for registering users of a website and login.

SOURCE CODE:

REGISTRATION.HTML:

<!DOCTYPE html>

<html>

<head>

<title>Signup</title>

</head>

<body>

<form action="registrationaccess.php" method="post">

<h1 align="center"> REGISTRATION </h1>

<table align="center" cellspacing="10">

<tr>

<td>Name::</td>

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

</tr>

<tr>

<td>Password::</td>

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

</tr>

<tr>

<td> E-mail ID:: </td>

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

</tr>

<tr>

<td> Mobile Number:: </td>

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

</tr>

<tr>

<td colspan="2" align="center">

<input type="submit" value="Register">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<input type="reset" value="Cancel"> </td>

</tr>

</table>

</form>

</body>

</html>

REGISTRATIONACCESS.PHP: 

<?php

$uname=$_POST["uname"];

$pwd=$_POST["pwd"];

$email=$_POST["email"];

$mobno=$_POST["mobno"];

$host="localhost";

$user="root";

$password="";

$con=mysqli_connect($host,$user,$password);

if($con) {

echo '<h1>Connected to MySQL</h1>';

$db=mysqli_select_db($con,"crr");

}

else {

echo '<h1>MySQL Server is not connected</h1>';

}

$q="insert into regs values('".$uname."','".$pwd."','".$email."',".$mobno.");";

$insert=mysqli_query($con,$q);

mysqli_close($con);

if(!$insert){

echo '<script>alert("Registration Failed."); window.location.href="registration.html";</script>';

}

echo '<script>alert("Successfully registered."); window.location.href="login.html";</script>';

?>

LOGIN.HTML:

<!DOCTYPE html>

<html>

<head>

<meta charset="ISO-8859-1">

<title>Login</title>

</head>

<body>

<h1 align="center">LOGIN</h1>

<form action="loginaccess.php" method="post">

<table align="center" cellspacing="10">

<tr>

<td><b>User Name</b></td>

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

</tr>

<tr>

<td><b>Password</b></td>

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

</tr>

<tr>

<td colspan="2" align="center">

<input type="Submit" value="Login"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<input type="reset">

</td>

</tr>

<tr>

<td colspan="2" align="right"><i><a href="registration.html">New User Click Here</a></i></td>

</tr>

</table>

</form>

</body>

</html>

LOGINACCESS.PHP: 

<!DOCTYPE html>

<html>

<head>

<title>Welcome</title>

</head>

<body>

<?php

$uid=$_POST["uid"];

$pass=$_POST["pwd"];

$host="localhost";

$user="root";

$password="";

$con=mysqli_connect($host,$user,$password);

if($con) {

echo '<h1>Connected to MySQL</h1>';

$db=mysqli_select_db($con,"crr");

}

else {

echo '<h1>MySQL Server is not connected</h1>';

}

$q="select * from regs;";

$retrecs=mysqli_query($con,$q);

if (!$retrecs) {

printf("Error: %s\n", mysqli_error($con));

exit();

}

while ($rec=mysqli_fetch_array($retrecs)) {

if ($rec["uname"]==$uid && $rec["pwd"]==$pass) {

$flag=1;

break;

}

}

mysqli_close($con);

if($flag==1){

echo "Welcome ".$uid;

}

else{

echo '<script>alert("Invalid User Name/Password"); window.location.href="login.html";</script>';

}

?>

</body>

</html>

OUTPUT:





EXPERIMENT-22:

AIM: Install a database (Mysql or Oracle).

Create a table which should contain at least the following fields: name, password, email-id,

phone number (these should hold the data from the registration form).

Write a PHP program to connect to that database and extract data from the tables and display

them. Experiment with various SQL queries.

Insert the details of the users who register with the web site, whenever a new user clicks the

submit button in the registration page.

SOURCE CODE:

REGISTRATION.HTML:

<!DOCTYPE html>

<html>

<head>

<title>Signup</title>

</head>

<body>

<form action="registrationaccess1.php" method="post">

<h1 align="center"> REGISTRATION </h1>

<table align="center" cellspacing="10">

<tr>

<td>Name::</td>

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

</tr>

<tr>

<td>Password::</td>

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

</tr>

<tr>

<td> E-mail ID:: </td>

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

</tr>

<tr>

<td> Mobile Number:: </td>

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

</tr>

<tr>

<td colspan="2" align="center"> <input type="submit" value="Register">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<input type="reset" value="Cancel"> </td>

</tr>

</table>

</form>

</body>

</html>

REGISTRATIONACCESS1.PHP:

<?php

//Accessing registration form details

$uname=$_POST["uname"];

$pwd=$_POST["pwd"];

$email=$_POST["email"];

$mobno=$_POST["mobno"];

$host="localhost";

$user="root";

$password="";

$con=mysqli_connect($host,$user,$password);

if($con) {

echo '<h1>Connected to MySQL</h1>';

//if connected then Select Database.

$db=mysqli_select_db($con,"crr");

}

else {

echo '<h1>MySQL Server is not connected</h1>';

}

//Inserting new user details

$q="insert into regs values('".$uname."','".$pwd."','".$email."',".$mobno.");";

$insert=mysqli_query($con,$q);

$q1="select *from regs";

$result=mysqli_query($con,$q1);

mysqli_close($con);

if(!$insert){

echo '<script>alert("Registration Failed."); window.location.href="registration.html";</script>';

}

echo '<script>alert("Successfully registered.");

</script>';

?>

<html>

<body>

<br/><br/><br/>

<p align="right"><a href="registration.html">[RegistrationPage]</a></p>

<center>

<font face="verdana"size="4">

<table border="1"cellpadding="0"cellspacing="0">

<tr>

<th>S.No.</th>

<th>UserName</th>

<th>Email</th>

<th>Mobile Number</th>

</tr>

<?php $num=1;

while($row=mysqli_fetch_array($result))

{?>

<tr>

<td><?php echo$num++;?></td>

<td><?php echo$row['uname'];?></td>

<td><?php echo$row['email'];?></td>

<td><?php echo$row['mobno'];?></td>

</tr>

<?php

}?>

</table>

</center>

</body>

</html>

OUTPUT:

EXPERIMENT-23:

AIM: Insert the details of the 3 or 4 users who register with the web site by using registration

form. Authenticate the user when he submits the login form using the username and password from the database.

SOURCE CODE:

REGISTRATION.HTML:

<!DOCTYPE html>

<html>

<head>

<title>Signup</title>

</head>

<body>

<form action="registrationaccess.php" method="post">

<h1 align="center"> REGISTRATION </h1>

<table align="center" cellspacing="10">

<tr>

<td>Name::</td>

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

</tr>

<tr>

<td>Password::</td>

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

</tr>

<tr>

<td> E-mail ID:: </td>

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

</tr>

<tr>

<td> Mobile Number:: </td>

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

</tr>

<tr>

<td colspan="2" align="center">

<input type="submit" value="Register">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<input type="reset" value="Cancel"> </td>

</tr>

</table>

</form>

</body>

</html>

REGISTRATIONACCESS.PHP: 

<?php

$uname=$_POST["uname"];

$pwd=$_POST["pwd"];

$email=$_POST["email"];

$mobno=$_POST["mobno"];

$host="localhost";

$user="root";

$password="";

$con=mysqli_connect($host,$user,$password);

if($con) {

echo '<h1>Connected to MySQL</h1>';

$db=mysqli_select_db($con,"crr");

}

else {

echo '<h1>MySQL Server is not connected</h1>';

}

$q="insert into regs values('".$uname."','".$pwd."','".$email."',".$mobno.");";

$insert=mysqli_query($con,$q);

mysqli_close($con);

if(!$insert){

echo '<script>alert("Registration Failed."); window.location.href="registration.html";</script>';

}

echo '<script>alert("Successfully registered."); window.location.href="login.html";</script>';

?>

LOGIN.HTML:

<!DOCTYPE html>

<html>

<head>

<meta charset="ISO-8859-1">

<title>Login</title>

</head>

<body>

<h1 align="center">LOGIN</h1>

<form action="loginaccess.php" method="post">

<table align="center" cellspacing="10">

<tr>

<td><b>User Name</b></td>

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

</tr>

<tr>

<td><b>Password</b></td>

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

</tr>

<tr>

<td colspan="2" align="center">

<input type="Submit" value="Login"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<input type="reset">

</td>

</tr>

<tr>

<td colspan="2" align="right"><i><a href="registration.html">New User Click Here</a></i></td>

</tr>

</table>

</form>

</body>

</html>

LOGINACCESS.PHP: 

<!DOCTYPE html>

<html>

<head>

<title>Welcome</title>

</head>

<body>

<?php

$uid=$_POST["uid"];

$pass=$_POST["pwd"];

$host="localhost";

$user="root";

$password="";

$con=mysqli_connect($host,$user,$password);

if($con) {

echo '<h1>Connected to MySQL</h1>';

$db=mysqli_select_db($con,"crr");

}

else {

echo '<h1>MySQL Server is not connected</h1>';

}

$q="select * from regs;";

$retrecs=mysqli_query($con,$q);

if (!$retrecs) {

printf("Error: %s\n", mysqli_error($con));

exit();

}

while ($rec=mysqli_fetch_array($retrecs)) {

if ($rec["uname"]==$uid && $rec["pwd"]==$pass) {

$flag=1;

break;

}

}

mysqli_close($con);

if($flag==1){

echo "Welcome ".$uid;

}

else{

echo '<script>alert("Invalid User Name/Password"); window.location.href="login.html";</script>';

}

?>

</body>

</html>

OUTPUT:

EXPERIMENT-24:

 AIM: Create tables in the database which contain the details of items (books in our case like Book name,Price, Quantity, Amount) of each category. Modify your catalogue page (week 2)in such a way that youshould connect to the database and extract data from the tables and display them in the catalogue page using PHP

 SOURCE CODE:

 

Catalogue table:

CREATE TABLE catalogue

(

bnamevarchar(50) NOT NULL,

auth varchar(25) NOT NULL,

publvarchar(25) NOT NULL,

isbnvarchar(20) NOT NULL,

edivarchar(10) NOT NULL,

cost int(5) NOT NULL,

qty int(3) NOT NULL,

UNIQUE KEY(bname)

)

 

bkEntryForm.html

<html>

<head>

<title> Catalogue Page</title>

<script language="javascript">

function validate()

{

var nam = document.f1.bname.value;

if(nam=="")

{

alert("Please enter Book name");

document.f1.bname.focus();

return false;

}

var auth = document.f1.auth.value;

if(auth=="")

{

alert("Please enter Author Name");

document.f1.auth.focus();

return false;

}

var publ = document.f1.publ.value;

if(publ=="")

{

alert("Please enter Publisher name");

document.f1.publ.focus();

return false;

}

var isbn = document.f1.isbn.value;

if(isbn=="")

{

alert("Please enter ISBN Number");

document.f1.isbn.focus();

return false;

}

var ed = document.f1.edi.value;

if(ed=="")

{

alert("Please enter book edition");

document.f1.edi.focus();

return false;

}

var cost = document.f1.cost.value;

if(cost=="")

{

alert("Please enter cost of the book");

document.f1.cost.focus();

return false;}

var qty = document.f1.qty.value;

if(qty=="")

{

 

</head>

<body>

}

}

</script>

 

alert("Please enter number of books you want!!!");

document.f1.qty.focus();

return false;

 

validate()">

 

<br/><br/><br/>

<center>

<form name="f1" action="Catalogue.php" method="post" onsubmit="javascript:return

<table border="3" cellpadding="0" cellspacing="0">

<tr>

<td>

<table cellspacing="5">

<tr>

<td colspan="2" align="center"><h2><u>Book Details Entry Form</u></h2></td>

</tr>

<tr>

<td> Book Name</td>

<td><input type="text" name="bname" size="50"></td>

 

</form>

</tr>

<tr>

<td> Author</td>

<td><input type="text" name="auth" size="50"></td>

</tr>

<tr>

<td> Publication</td>

<td><input type="text" name="publ" size="50"></td>

</tr>

<tr>

<td> ISBN</td>

<td><input type="text" name="isbn" size="15"></td>

</tr>

<tr>

<td> Edition</td>

<td><input type="text" name="edi" size="15"></td>

</tr>

<tr>

<td> Cost</td>

<td>$<input type="text" name="cost" size="5"></td>

</tr>

<tr>

<td> Quantity</td>

<td><input type="text" name="qty" size="3"></td>

</tr>

<tr>

<td colspan="2" align="center"><input type="submit" value="submit"></td>

</tr>

</table>

</td>

</tr>

</table>

</center>

</body>

</html>

 

Catalogue.php

<?php

$conn = mysql_connect("localhost","root","");

if($conn)

echo "Connected to database!!!";

else

echo "Failed to Connect:".mysql_error();

mysql_select_db("test",$conn) or die("No Database existing:".mysql_error());

if(isset($_POST['bname']))

{

$bname=$_POST['bname'];

$auth=$_POST['auth'];

$publ=$_POST['publ'];

$isbn=$_POST['isbn'];

$edi=$_POST['edi'];

$cost=(float)$_POST['cost'];

$qty=(int)$_POST['qty'];

echo"<br/><br/><br/><p align='right'><a href='bkEntryForm.html'>[Book Entry Page]</a></p>";

$query = "INSERT INTO catalogue VALUES('$bname','$auth','$publ','$isbn','$edi','$cost','$qty')";

mysql_query($query);

$result = mysql_query("select * from catalogue");

?>

<html>

<body><center>

<font face="verdana" size="4">

<table border="1" cellpadding="0" cellspacing="0">

<tr>

</tr>

<tr>

<thcolspan="8" align="center">Books List</td>

<th>S.No.</th>

<th>Title</th>

<th>Author</th>

<th> Publication</th>

<th>ISBN</th>

<th>Edition</th>

<th>Cost</th>

<th>Quantity</th>

</body>

</html>

</tr>

<?php $num=1; while($row = mysql_fetch_array($result))

{ ?>

<tr>

<td align="center"><?php echo $num++; ?></td>

<td align="left"><?php echo $row['bname']; ?></td>

<td align="left"><?php echo $row['auth']; ?></td>

<td align="left"><?php echo $row['publ']; ?></td>

<td align="center"><?php echo $row['isbn']; ?></td>

<td align="center"><?php echo $row['edi']; ?></td>

<td align="center"><?php echo $row['cost']; ?></td>

<td align="center"><?php echo $row['qty']; ?></td>

</tr>

<?php }?>

</table>

</center>

<?php } ?>

 OUT PUT:

­­­­­EXPERIMENT-25:

 

AIM: HTTP is a stateless protocol. Session is required to maintain the state.

The user may add some items to cart from the catalog page. He can check the cart page for the selected items. He may visit the catalogue again and select some more items. Here our interest is the selected items should be added to the old cart rather than a new cart. Multiple users can dothe same thing at a time(i.e., from different systems in the LAN using the ip-address instead of local host). This can be achieved through the use of sessions. Every user will have his own session which will be created after his successful login to the website. When the user logs out his

session should get invalidated (by using the method session. Invalidate ().

Modify your catalogue and cart PHP pages to achieve the above mentioned functionality using

sessions.

 

SOURCE CODE:

 

style.css

body

{

width:800px;

}

.txt-heading

{

padding: 5px 10px;

font-size:1.1em;

font-weight:bold;

color:#999;

}

.btnRemoveAction

{

color:#D60202;

border:0;

padding:2px 10px;

font-size:0.9em;

}

#btnEmpty

{

background-color:#D60202;

border:0;

padding:1px 10px;

color:#FFF;

font-size:0.8em;

font-weight:normal;

float:right;

text-decoration:none;

}

.btnAddAction

{

background-color:#79b946;

border:0;

padding:3px 10px;

color:#FFF;

margin-left:1px;

}

#shopping-cart

{

border-top: #79b946 2px solid;

margin-bottom:30px;

}

#shopping-cart .txt-heading

{

background-color: #D3F5B8;

}

#shopping-cart table

{

width:100%;

background-color:#F0F0F0;

}

{

background-color:#FFFFFF;

}

.cart-item

{

border-bottom: #79b946 1px dotted;

padding: 10px;

}

#product-grid

{

border-top: #F08426 2px solid;

margin-bottom:30px;

}

#product-grid .txt-heading

{

background-color: #FFD0A6;

}

.product-item {

float:left;

background:#F0F0F0;

margin:15px;

padding:5px;

}

.product-item div

{

text-align:center;

margin:10px;

}

.product-price

{

color:#F08426;

}

.product-image {

height:100px;

background-color:#FFF;

}

dbController.php

<?php

class DBController {

private $host = "localhost";

private $user = "root";

private $password = "";

private $database = "test";

function construct() {

$conn = $this->connectDB();

if(!empty($conn)) {

$this->selectDB($conn);

}

}

function connectDB() {

$conn = mysql_connect($this->host,$this->user,$this->password);

return $conn;

}

function selectDB($conn) {

mysql_select_db($this->database,$conn);

}

function runQuery($query) {

$result = mysql_query($query);

while($row=mysql_fetch_assoc($result)) {

$resultset[] = $row;

}

if(!empty($resultset))

return $resultset;

}

 

index.php

 

<?php

session_start();

require_once("dbcontroller.php");

$db_handle = new DBController();

if(!empty($_GET["action"])) {

switch($_GET["action"]) {

case "add":

if(!empty($_POST["quantity"])) {

$productByCode = $db_handle->runQuery("SELECT * FROM tblproduct WHERE

code='" . $_GET["code"] . "'");

$itemArray =

array($productByCode[0]["code"]=>array('name'=>$productByCode[0]["name"],

'code'=>$productByCode[0]["code"], 'quantity'=>$_POST["quantity"], 'price'=>$productByCode[0]["price"]));

= $_POST["quantity"];

if(!empty($_SESSION["cart_item"])) {

if(in_array($productByCode[0]["code"],$_SESSION["cart_item"])) {

foreach($_SESSION["cart_item"] as $k => $v) {

if($productByCode[0]["code"] == $k)

$_SESSION["cart_item"][$k]["quantity"]

} else {

}

$_SESSION["cart_item"] =

array_merge($_SESSION["cart_item"],$itemArray);

}

}

break;

} else {

}

$_SESSION["cart_item"] = $itemArray;

case "remove":

if(!empty($_SESSION["cart_item"])) {

foreach($_SESSION["cart_item"] as $k => $v) {

if($_GET["code"] == $k)

unset($_SESSION["cart_item"][$k]);

}

}

break;

if(empty($_SESSION["cart_item"]))

unset($_SESSION["cart_item"]);

case "empty":

unset($_SESSION["cart_item"]);

break;

}

}

?>

<HTML>

<HEAD>

<TITLE>Simple PHP Shopping Cart</TITLE>

<link href="style.css" type="text/css" rel="stylesheet" />

</HEAD>

<BODY>

<div id="shopping-cart">

<div class="txt-heading">Shopping Cart <a id="btnEmpty" href="index.php?action=empty">Empty Cart</a></div>

<?php

if(isset($_SESSION["cart_item"])){

$item_total = 0;

?>

<table cellpadding="10" cellspacing="1">

<tbody>

<tr>

<th><strong>Name</strong></th>

<th><strong>Code</strong></th>

<th><strong>Quantity</strong></th>

<th><strong>Price</strong></th>

<th><strong>Action</strong></th>

</tr>

<?php

foreach ($_SESSION["cart_item"] as $item){

?>

<tr>

<td><strong><?php echo $item["name"]; ?></strong></td>

<td><?php echo $item["code"]; ?></td>

<td align=center><?php echo $item["quantity"]; ?></td>

<td align=right><?php echo "$".$item["price"]; ?></td>

<td><a href="index.php?action=remove&code=<?php echo $item["code"];

?>" class="btnRemoveAction">Remove Item</a></td>

</tr>

<?php

$item_total += ($item["price"]*$item["quantity"]);

}

?>

<tr>

<td colspan="5" align=right><strong>Total:</strong><?php echo "$".$item_total; ?></td>

</tr>

</tbody>

</table>

<?php

}

?>

</div>

<div id="product-grid">

<div class="txt-heading">Products</div>

<?php

$product_array = $db_handle->runQuery("SELECT * FROM tblproduct ORDER BY id ASC");

if (!empty($product_array)) {

foreach($product_array as $key=>$value){

?>

<div class="product-item">

<form method="post" action="index.php?action=add&code=<?php echo

$product_array[$key]["code"]; ?>">

<div class="product-image"><imgsrc="<?php echo $product_array[$key]["image"];

?>" height="100" width="75"></div>

<div><strong><?php echo $product_array[$key]["name"]; ?></strong></div>

<div class="product-price"><?php echo "$".$product_array[$key]["price"]; ?></div>

<div><input type="text" name="quantity" value="1" size="2" /><input type="submit"

value="Add to cart" class="btnAddAction" /></div>

</form>

</div>

<?php

}

?>

</div>

}

</body>

</html>

 OUTPUT:






























Blog Archive