Final 336
Final 336
Practical 4.1
Aim: Using Angular JS, user get input value search box and enter it in AngularJS
component using Enter key.
HTML CODE:
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js"></script>
</head>
<body ng-controller="MyController">
<div>
angular.module('myApp', []);
$scope.searchText = '';
$scope.searchResult = '';
$scope.searchResult = $scope.searchText;
};
});
</script>
</body>
</html>
OUTPUT:
Practical 4.2
AIM :Using Angular JS features make a shopping list/To-do list where you can
add or remove items.
HTML CODE:
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js"></script>
</head>
<body ng-controller="ListController">
<div>
<button ng-click="addItem()">Add</button>
</div>
<ul>
{{ item }}
<button ng-click="removeItem($index)">Remove</button>
</li>
angular.module('myApp', []);
$scope.items = [];
$scope.newItem = '';
$scope.addItem = function () {
$scope.items.push($scope.newItem);
$scope.newItem = '';
};
$scope.items.splice(index, 1);
};
});
</script>
</body>
</html>
OUTPUT:
Practical-5.1
AIM: PHP based web application to understand data retrieval on server side.
Code:
Index.html:
<html>
<head>
</head>
<body>
<form method="get" name="reg" action="reg1.php" enctype="text/plain">
<fieldset align="center">
<legend>Registration form</legend>
<table border="0" height="*" width="*" cellspacing="10" cellpadding="5" align="center">
<tr>
<td>Enter username</td>
<td>
<input type="text" name="uname" placeholder="Enter username">
</td></tr>
<tr>
<td>Enter password</td>
<td>
<input type="password" name="pwd" placeholder="Enter password" required>
</td></tr>
<tr>
<td>Enter email</td>
<td>
<input type="email" name="email" placeholder="Enter Email" required>
</td></tr>
<tr>
<td>Contact Number</td>
<td>
<input type="number" name="mob" size="10" required>
</td></tr>
<tr>
<td>DOB</td>
<td>
<input type="date" name="dob">
</td></tr>
<tr>
<td>Gender</td>
<td>
<input type="radio" name="gen" value="Male" checked> Male
<input type="radio" name="gen" value="Female"> Female
<input type="radio" name="gen" value="Other"> Other
</td>
</tr>
<tr>
<td>Select city</td>
<td>
<select name="city" multiple>
<option value="">Select city</option>
<option value="amd">Ahmedabad</option>
<option value="srt">Surat</option>
<option value="rkt">Rajkot</option>
<option value="mum">Mumbai</option>
<option value="bng">Banglore</option>
<option value="kol">Kolkata</option>
</td></tr>
<tr>
<td>Select state</td>
<td>
INDU UNIVERSITY CSE E2 7
Web Technology SEM - 5 IU2241231336
Reg1.php:
<?php
$uname = $_GET["uname"];
$pwd = $_GET["pwd"];
$email = $_GET["email"];
$mob = $_GET["mob"];
$dob = $_GET["dob"];
$gen = $_GET["gen"];
$city = $_GET["city"];
$state = $_GET["state"];
$address = $_GET["address"]; $hob = $_GET["hob"]; echo "<table border cellspacing='10px'
cellpadding='10px' align=center>
<caption><h1>Result</h1></caption>
<tr>
<td>Name</td>
<td>$uname</td>
<tr>
<tr>
<td>Email</td>
<td>$email</td>
</tr>
<tr>
<td>Mobile number</td>
<td>$mob</td>
</tr>
<tr>
<td>DOB</td>
<td>$dob</td>
</tr>
<tr>
<td>Gender</td>
<td>$gen</td>
</tr>
<tr>
<td>City</td>
<td>$city</td>
</tr>
<tr>
<td>State</td>
<td>$state</td>
</tr>
<tr>
<td>Address</td>
<td>$address</td>
</tr>
</table>
?>
Output:
Practical-5.2
AIM: Include, require, date functions in php.
Code:
<?php include 'header.php';
require 'con.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SignUp Form</title>
</head>
<body>
<form action="insert.php" method="post">
<label for="email">Email: </label>
<input type="email" name="email" id="email"><p>
<label for="password">Password: </label>
<input type="password" name="password" id="password"><p>
<input type="submit" value="Sumbit">
</form>
</body>
</html>
header.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
con.php
<?php
$conn = mysqli_connect('localhost', 'root', '', 'demo');
if (!$conn)
{
die('Connection failed: ' . mysqli_connect_error());
}
else{
// echo "Connection Pass";
}
?>
insert.php
<?php
require 'con.php';
$email = $_REQUEST['email'];
$password = $_REQUEST['password'];
$signup_date = date("d/m/Y");
$sql = "INSERT INTO signup (email, password, date) VALUES ('$email', '$password',
'$signup_date')";
if ($conn->query($sql) === TRUE)
{
echo "New record created successfully";
}
?>
Output:
Practical-5.3
AIM: Develop PHP web application using session and cookie.
Code:
Using session:
Index1.html:
<form method="get" action="session.php">
<input type="text" name="name">
<input type="submit" name="submit" value="Register">
</form>
s1.php :
<?php
session_start(); echo "Hello ".$_SESSION['name'];
?>
<br>
<a href="destroy.php">Logout</a>
session.php : <?php
session_start(); if(isset($_REQUEST['name']) &&
$_REQUEST['name']!=null)
{
$_SESSION['name']=$_REQUEST['name']; header('Location:s1.php');
}
else
{
header('Location:index1.php');
}
?>
destroy.php:
<?php
session_start();
session_destroy();
header('Location:index1.php');
?>
Output:
Using cookie :
index2.html :
<form method="get" action="session1.php">
<input type="text" name="name">
<input type="submit" name="submit" value="Register">
</form>
c1.php :
<?php
session_start(); echo "Hello ".$_COOKIE['name'];
?>
<br>
<a href="destroy1.php">Logout</a>
session1.php:
<?php
if(isset($_REQUEST['name']) && $_REQUEST['name']!=null)
{
$VALUE=$_REQUEST['name'];
setcookie("name",$VALUE,time()+3600);
header('Location:c1.php');
}
else
{
header('Location:index2.php');
}
?>
destroy1.php :
<?php setcookie("uname","",time()-3600);
INDU UNIVERSITY CSE E2 17
Web Technology SEM - 5 IU2241231336
header('Location:index2.php');
?>
Output:
Practical-5.4
AIM: Understand PHP MyAdmin.
phpMyAdmin is a free and open-source web-based administration tool for managing MySQL
and MariaDB databases. It provides a user-friendly graphical interface that simplifies database
administration tasks, making it accessible to both beginners and experienced database
administrators. In this document, we will explore the key features and functionalities of
phpMyAdmin, its installation, and common use cases.
Table of Contents
1. Installation
• Web-based Installation
• Manual Installation
• Configuration
2. User Interface
• Dashboard
• Navigation Pane
• Main Work Area
3. Database Operations
• Creating Databases
• Creating Tables
• Importing and Exporting Data
• Querying Databases
4. User Management
• Creating Users
• Setting Privileges
6. Advanced Features
• SQL Query Editor
• Designer Tool
• Exporting Database as SQL
7. Security Considerations
□ Securing phpMyAdmin
Configuration :
After installation, you may need to configure phpMyAdmin to connect to your MySQL or
MariaDB server. You can set up database credentials and other settings in the config.inc.php
file.
3. Database Operations
Creating Databases
You can create new databases directly from phpMyAdmin. Provide a name and choose a
character set and collation for the database.
Creating Tables:
Inside a database, you can create tables with specific columns, data types, and constraints.
phpMyAdmin offers a visual table designer for this purpose.
Importing and Exporting Data:
You can import and export data in various formats, including SQL, CSV, and Excel. This makes
it easy to back up your databases or transfer data between systems.
Querying Databases:
phpMyAdmin includes a SQL query editor where you can run SQL queries to retrieve, update,
or delete data from your databases. It supports syntax highlighting and auto-completion.
Practical 5.5
AIM: Implement php application to store employee records in MySQL
database.
Code:
<!DOCTYPE html>
<head>
<body>
<tr>
<td>Company Id:</td>
</tr>
<tr>
<td>Full name:</td>
</tr>
<tr>
<td>Date of Birth:</td>
placeholder=""> </td>
</tr>
<tr>
<td>Gender:</td>
<td>
checked> Male
</td>
</tr>
<tr>
<td>Email:</td>
</tr>
<tr>
<td>Phone number:</td>
</tr>
<tr>
<td>Select city:</td>
<td>
<option value="Ahmedabad">Ahmedabad</option>
<option value="Baroda">Baroda</option>
<option value="Rajkot">Rajkot</option>
<option value="Surat">Surat</option>
</td>
</tr>
<tr>
<td>Enter zipcode:</td>
</tr>
</table>
<br>
<legend align="center">
</legend>
</form>
<br><br>
</body>
</head>
</html>
<?php if(isset($_POST['submit']))
$cid=$_POST['cid'];
$name=$_POST['fname'];
$mail=$_POST['email'];
$pno=$_POST['number'];
$dob=$_POST['DOB'];
$gender=$_POST['gender'];
$city=$_POST['city'];
$zip=$_POST['zipcode'];
$con=mysqli_connect("localhost","root","","mysql");
$tab="INSERT INTO `emp_reg`(`Company_id`, `Full_name`, `DOB`, `Gender`, `Email`,
`Phone_number`,`City`,`Zip`)VALUES('$cid','$name','$dob','$gender','$mail',$pno,'$city','$zi
p')";
mysqli_query($con,$tab);
echo "<h4 align='center'>Following are the details added to PHP MYSQL database:</h4>";
<tr>
<th>Company Id</th><th>Full
name</th><th>DOB</th><th>Gender</th><th>Email</th><th>Phone
number</th><th>City</th><th>Zip</th>
</tr>";
if(mysqli_num_rows($res)>0)
While($x=mysqli_fetch_array($res))
{ echo
"<tr>
<td>$x[0]</td>
<td>$x[1]</td>
<td>$x[2]</td>
<td>$x[3]</td>
<td>$x[4]</td>
<td>$x[5]</td>
<td>$x[6]</td>
<td>$x[7]</td>
</tr>";
} else {
echo "<tr>
</tr>"; }
echo
"</table>";
?>
Output:
CSE-E2