You are on page 1of 20

Practical - 1

AIM: - A Simple HTML home page provide links to move to other pages like hobbies,
educational info, personal info etc.

<html>

<head>

<title>My First Web Page</title>

</head>

<body bgcolor="cyan" text="red">

<center><u><h1>HOME PAGE</h1></u></center>

<u><h2>Hello My Self</h2></u>

<h4>1.hobbies</h4>

<a href="1_1.html">click here for known my Hobbies</a>

<h4>2.Educational Info</h4>

<a href="1_2.html">click here for known my Education Info</a>

<h4>3.Personal Info</h4>

<a href="1_3.html">click here for known my Personal Info</a>

</body>

</html>

OUTPUT: -
Practical – 2
AIM: - A HTML program to illustrate the use of frame and frameset tags of HTML.

<html>

<head>
<title>HTML Frames</title>
</head>

<frameset rows = "20%,40%,30%">


<frame name = "top" src = "/html/top_frame.htm" />
<frame name = "main" src = "/html/main_frame.htm" />
<frame name = "bottom" src = "/html/bottom_frame.htm" />

</frameset>

</html>

OUTPUT: -
Practical – 3
AIM: - A HTML Program which use a HTML controls to create a student information form
to collect student’s information like name, address, phone, email, sex, birth date, hobbies etc.
Download

<html>

<head>

<title>

creation of form

</title>

</head>

<body bgcolor="white">

<center><h1><u>student record</u></h1></center>

<br><br>

<form>

First name<input type="text" name="first name" place order="first name"><br><br><br>

Last name <input type="text" name="last name" place order="last name"><br><br><br>

address <input type="text" name="address" place holder="enter address"><br><br><br>

phone <input type="text" name="phone" place holder="enter phone no."><br><br><br>

email <input type="text" name="email" place holder="enter email"><br><br><br>

Birthdate<input type="text" name="birthdate" place order="enter d.o.b"><br><br><br>

Hobbies<input type="text" name="hobbies" place order="enter your hobbies"><br><br><br>

Gender: <input type="radio" name="rb2" checked/>M

<input type="radio" name="rb2" checked/>F <br><br>

<center><input type="button"value="download"></center>

</body>

</html>
OUTPUT: -
Practical – 4
AIM: - A HTML Program which demonstrates loops like for loop, do while, while in java
script.

<html>
<head>
<script type="text/javascript">
var students = new Array("shubham", "sonu", "rakesh", "sunny", "aniket");
document.write("<b>Using for loops </b><br />");
for (i=0;i<students.length;i++)
{
document.write(students[i] + "<br />");
}
</script><br>
<script type="text/javascript">
document.write("<b>Using while loops </b><br />");
var i = 0, j = 1, k;
document.write("Fibonacci series less than 40<br />");
while(i<40)
{
document.write(i + "<br />");
k = i+j;
i = j;
j = k;
}
</script><br>
<script type="text/javascript">
document.write("<b>Using do...while loops </b><br />");
var i = 2;
document.write("Even numbers less than 20<br />");
do
{
document.write(i + "<br />");
i = i + 2;
}while(i<20)
</script>
</head>
<body>
</body>
</html>
Output: -
Practical – 5
AIM: - A HTML Program which demonstrates the use of functions in java script.
<html>
<head>
<script type = "text/javascript">

function welcomeMsg(name) {
document.write("Hello " + name + " welcome to My Webpage");
}
var nameVal = "Admin";

welcomeMsg(nameVal);
</script>
</head>
<body>
</body>
</html>

Output: -
Practical – 6
AIM: - A HTML Program which demonstrates various events like onclick, onblur, ,
onmouseover, onload event.

<html>
<body>
<h1>onclick button </h1>
<button onclick="document.getElementById('demo').innerHTML=Date()">The time
is?</button>

<p id="demo"></p>
<br>
<h1>onblur button</h1>
<p>When you enter the input field, a function is triggered which sets the background color to
yellow.
When you leave the input field, a function is triggered which sets the background color to
red.</p>
Enter your name: <input type="text" id="myInput" onfocus="focusFunction()"
onblur="blurFunction()">
<script>
function focusFunction() {
document.getElementById("myInput").style.background = "yellow";
}
function blurFunction() {
document.getElementById("myInput").style.background = "red";

}</script>
<br>
<h1>onmouseover type</h1>
<p>This example demonstrates how to assign an "onmouseover" and "onmouseout" event to
a h1 element.</p>
<h1 id="demo" onmouseover="mouseOver()" onmouseout="mouseOut()">Mouse over
me</h1>
<script>
function mouseOver() {
document.getElementById("demo").style.color = "red";

}
function mouseOut() {
document.getElementById("demo").style.color = "black";
}
</script>

<h1>onload button</h1>
<p>this example demonstrate how to assign an "onload"</p>
<h1 onclick="this.innerHTML='Ooops!'">Click on this text!</h1>
</body>
</html>

Output: -
Practical – 7
AIM: - A HTML Program to create various functions and sub routines to validate the
data entered by user in form.

<html>
<body>
<h2>A HTML Program Can Validate Input</h2>

<p>Please input a number between 1 and 10:</p>


<input id="numb">
<button type="button" onclick="myFunction()">Submit</button>
<p id="demo"></p>
<script>

function myFunction() {
var x, text;
x = document.getElementById("numb").value;
if (isNaN(x) || x < 1 || x > 10) {
text = "Input not valid";

} else {
text = "Input OK";
}
document.getElementById("demo").innerHTML = text;
}

</script>

</body>
</html>
Output: -
Practical – 8
AIM: - Create a program to illustrate the concept of associative array in PHP.

<?php
$age = array("ram"=>"35", "shyam"=>"37", "aman"=>"43");
echo "aman is " . $age['aman'] . " years old.";
?>

Output: -
Practical – 9
AIM: - Create PHP program to implement the concept of Session management.

<?php
session_start();
$_session["username"]="session value represent here";

echo $_session["username"];
?>

Output:-
Practical – 10
AIM: - Create a PHP program to display student information in webpage. Student’s
data is stored in My SQL database.

<html>
<head>
<title>Table with database</title>
</head>
<body>

<table>
<tr>
<th>Id</th>
<th>name</th>
<th>email</th>

</tr>
<?php
$conn = mysqli_connect("localhost", "root", "", "new");

if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT id, name, email FROM record";
$result = $conn->query($sql);
if ($result->num_rows > 0) {

while($row = $result->fetch_assoc()) {
echo "<tr><td>" . $row["id"]. "</td><td>" . $row["name"] . "</td><td>"
. $row["email"]. "</td></tr>";
}

echo "</table>";
} else { echo "0 results"; }
$conn->close();
?>

</table>
</body>
</html>

Output: -
Practical – 11
AIM: - Create a PHP program to insert student information from HTML form. Student’s data
is stored in My SQL database.
Part 1:- HTML file that show the Form Design code.
<html>

<head>
<meta charset="UTF-8">
<title>Register Form</title>

</head>

<body>
<form action="insert.php" method="POST">
<table>
<tr>
<td>Name :</td>

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


</tr>
<tr>
<td>Password :</td>
<td><input type="password" name="password"></td>

</tr>
<tr>
<td>Gender :</td>
<td>
<input type="radio" name="Gender" value="m"> Male

<input type="radio" name="Gender" value="f"> Female


</td>
</tr>
<tr>
<td>Email :</td>
<td><input type="email" name="email"></td>
</tr>

<tr>
<td>Phone no :</td>
<td>
<select name="phonecode">
<option select hidden value="">select code</option>

<option value="977">977</option>
<option value="978">978</option>
<option value="979">979</option>
<option value="973">973</option>
<option value="972">972</option>

<option value="974">974</option>
</select>
<input type="phone" name="phone">
</td>
</tr>

<tr>
<td><input type="submit" value="Submit"></td>
</tr>
</table>
</form>

</body>
</html>
Part 2:- PHP file that Show How to retrieve Data From Form And store in the Database and
Also show How to connect html to database. This file name as insert.php
<?php
$username = $_POST['username'];
$password = $_POST['password'];
$gender = $_POST['Gender'];
$email = $_POST['email'];
$phoneCode = $_POST['phonecode'];

$phone = $_POST['phone'];
if (!empty($username) || !empty($password) || !empty($gender) || !empty($email) ||
!empty($phoneCode) || !empty($phone)) {
$host = "localhost";
$dbUsername = "root";
$dbPassword = "";
$dbname = "detail";

//create connection
$conn = new mysqli($host, $dbUsername, $dbPassword, $dbname);
if (mysqli_connect_error()) {
die('Connect Error('. mysqli_connect_errno().')'. mysqli_connect_error());
} else {

$SELECT = "SELECT email From register Where email = ? Limit 1";


$INSERT = "INSERT Into register (username, password, gender, email, phoneCode, phone)
values(?, ?, ?, ?, ?, ?)";
//Prepare statement
$stmt = $conn->prepare($SELECT);
$stmt->bind_param("s", $email);

$stmt->execute();
$stmt->bind_result($email);
$stmt->store_result();
$rnum = $stmt->num_rows;
if ($rnum==0) {

$stmt->close();
$stmt = $conn->prepare($INSERT);
$stmt->bind_param("ssssii", $username, $password, $gender, $email, $phoneCode,
$phone);
$stmt->execute();
echo "New record inserted sucessfully";
} else {

echo "Someone already register using this email";


}
$stmt->close();
$conn->close();
}

} else {
echo "All field are required";
die();
}
?>

Output: -
1. Form Desgin page
2. Message Page that show data inserted successfully.

3. Database Show the Inserted Data.

You might also like