WTF260
WTF260
WTF260
Aim: Develop a registration form by using various form elements like input
box, text area, radio buttons, check boxes etc.
Html code:
<html>
<head>
<script type="text/javascript" src="validate.js"></script>
</head>
<body>
<form action="#" name="StudentRegistration">
<center><font size=4><b>Student Registration Form</b></font></center>
Name
<input type="text" name="textnames" id="textname" size="30"><br><br>
Father Name
<input type=”text" name="fathername" id="fathername" size="30"><br><br>
Postal Address
<input type="text" name="paddress" id="paddress" size="30"><br><br>
Personal Address
<input type="text" name="personaladdress" id="personaladdress" size="30"><br><br>
Sex
<input type="radio" name="sex" value="male" size="10">Male
<input type="radio" name="sex" value="Female" size="10">Female<br><br>
City
<select name="City">
<option value="-1" selected>select..</option>
<option value="New Delhi">NEW DELHI</option>
<option value="Mumbai">MUMBAI</option>
<option value="Goa">GOA</option>
<option value="Patna">PATNA</option>
</select><br><br>
Course
<td><select name="Course">
<option value="-1" selected>select..</option>
<option value="B.Tech">B.TECH</option>
<option value="MCA">MCA</option>
<option value="MBA">MBA</option>
<option value="BCA">BCA</option>
</select><br><br>
District
<select name="District">
<option value="-1" selected>select..</option>
<option value="Nalanda">NALANDA</option>
//internal CSS
<!DOCTYPE html>
<html>
<head>
<style>
body{
background-color:linen;
}
h1{
//inline CSS
<!DOCTYPE html>
<html>
<body>
<h1 style="color:blue;text-align:center;">
inline CSS
</h1>
<p style="color: red;">
This is a inline css</p>
</body>
</html>
Output:
Aim: Create an HTML file to implement the styles related to text , fonts , links
using cascading style sheets
HTML Code:
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-color: lightgrey;
color: blue;
text-indent: 50px;
}
h1
{
background-color: black;
color: white;
text-align: center;
text-decoration: underline;
text-transform: uppercase;
text-shadow: 2px 2px red;
}
.serif
{
font-family: "Times New Roman", Times, serif;
}
.sansserif
{
font-family: Arial, Helvetica, sans-serif;
font-style: italic;
font-size: 20px;
}
.monospace
{
font-family: "Lucida Console", Courier, monospace;
}
a:link
{
color: red;
}
a:visited
{
Solution:
<!DOCTYPE html>
<html>
<head>
<title>GET ELEMENT</title>
<style>
body{
background-color:rgb(122, 165, 127);
text-align: center;
font-size: 20px;
font-family:'Lucida Sans', 'Lucida Sans Regular';
color: #9b620c;
margin-top: 120px;
}
</style>
</head>
<body>
<h2>Finding HTML Elements by Id</h2>
<p id="intro">Nitin Gupta</p>
<p id="demo"></p>
<script>
var myElement = document.getElementById("intro");
document.getElementById("demo").innerHTML ="My Name is " + myElement.innerHTML;
</script>
</body>
</html>
Output:
OUTPUT:
}
</script>
</body>
</html>
Output:
Aim:- Create an HTML page including JavaScript that takes a given set of
integer numbers and shows them after sorting in descending order.
HTML CODE:
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Array Sort</h2>
<p>Click the button to sort the array in descending order.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
var points = [40, 100, 1, 5, 25, 10];
document.getElementById("demo").innerHTML= points;
function myFunction()
{
points.sort(function(a, b){return b - a});
document.getElementById("demo").innerHTML = points;
}
</script>
</body>
</html>
OUTPUT:
OBJECTIVE: Write an HTML page including any required JavaScript that takes
a number from one text field in the range of 0 to 999 and shows it in another
text field in words. If the number is out of range, it should show “out of range”
and if it is not a number, it should show “not a number” message in the result
box
HTML Code
<!DOCTYPE html>
<html>
<head>
<title>GET ELEMENT</title>
<style>
body{
background-color:rgb(78, 36, 95);
text-align: center;
font-size: 20px;
font-family:'Lucida Sans', 'Lucida Sans Regular';
color: #cac2ce;
margin-top: 120px;
}
</style>
</head>
<body>
<button onclick="myFunction()">CLICK ON A BUTTON TO INPUT A NUMBER</button
>
<p id="a"></p>
<script>
function myFunction()
{
var num = prompt("Please enter your number", "0-999");
document.getElementById("a").innerHTML=num;
if(num>=0 && num<=999)
{
var res=num.toString().split("");
document.getElementById("a").innerHTML=res;
var s="";
var i;
for(i=0;i<res.length;i++)
{
if(res[i]=='0')
}
}
</script>
</body>
</html>
OUTPUT:
vowel or consonant
<?php
$ch='r';
switch($ch)
{
case 'a':
echo "Character is vowel";
break;
case 'e':
echo "Character is vowel";
break;
case 'i':
echo "Character is vowel";
break;
case 'o':
cube of integer
<?php
function cube($n)
{
$sum=0;
for($x=1; $x<=$n; $x++)
$sum=$x*$x*$x;
return $sum;
}
$n=7;
echo cube($n);
?>
Output:
right triangle
OUTPUT:
Welcome Janvi
Your email address is [email protected]
b) POST METHOD
<!DOCTYPE HTML>
<html>
<head>
<style>
.error {color: #FF0000;}
</style>
</head>
<body>
<?php
// define variables and set to empty values
$nameErr = $emailErr = $genderErr = $websiteErr = "";
$name = $email = $gender = $comment = $website = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["name"])) {
$nameErr = "Name is required";
} else {
$name = test_input($_POST["name"]);
if (!preg_match("/^[a-zA-Z-' ]*$/",$name)) {
$nameErr = "Only letters and white space allowed";
}
}
if (empty($_POST["email"])) {
$emailErr = "Email is required";
} else {
$email = test_input($_POST["email"]);
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$emailErr = "Invalid email format";
}
}
if (empty($_POST["website"])) {
$website = "";
} else {
$website = test_input($_POST["website"]);
Aim: A simple calculator web application that takes two numbers and an
operator (+,-, /, * and %) from an HTML page and returns the result page with
the operation
performed on the operands.
HTML Code:
<html>
<head>
<script>
//function that display value
function dis(val)
{
document.getElementById("result").value+=val
}
input[type="button"]
{
background-color:green;
input[type="text"]
{
background-color:white;
border: solid black 2px;
width:100%
}
</style>
</head>
<!-- create table -->
<body>
<div class = title >Calculator</div>
<table border="1">
<tr>
<td colspan="3"><input type="text" id="result"/></td>
<!-- clr() function will call clr to clear all value -->
<td><input type="button" value="c" onclick="clr()"/></td>
</tr>
<tr>
<!-- create button and assign value to each button -->
<!-- dis("1") will call function dis to display value -->
<td><input type="button" value="1" onclick="dis('1')"/></td>
<td><input type="button" value="2" onclick="dis('2')"/></td>
<td><input type="button" value="3" onclick="dis('3')"/></td>
<td><input type="button" value="/" onclick="dis('/')"/></td>
</tr>
<tr>
<td><input type="button" value="4" onclick="dis('4')"/></td>
<td><input type="button" value="5" onclick="dis('5')"/></td>
<td><input type="button" value="6" onclick="dis('6')"/></td>
<td><input type="button" value="-" onclick="dis('-')"/></td>
</tr>
<tr>
<td><input type="button" value="7" onclick="dis('7')"/></td>
<td><input type="button" value="8" onclick="dis('8')"/></td>
<td><input type="button" value="9" onclick="dis('9')"/></td>
<td><input type="button" value="+" onclick="dis('+')"/></td>
</tr>
<tr>
<td><input type="button" value="." onclick="dis('.')"/></td>
OUTPUT:
AIM: Implement login page contains the user name and the password of the user to
authenticate with Session using PHP and MySQL, also implement this with the
help of PHP-Ajax.
Html code:
<!DOCTYPE html>
<html>
<head>
<script>
function _(el) {
return document.getElementById(el);
}
}
return true;
}
function validate_email(fld) {
with (fld)
{
apos = value.indexOf("@");
dotpos = value.lastIndexOf(".");
<div>
<span id="login-response"></span>
<div>
<label for="name">Username</label>
<input type="text" name="username" id="username" placeholder="username">
</div>
<div>
<label for="email">Password</label>
<input type="password" name="password" id="password" placeholder="Password">
</div>
<div>
<input type="submit" value="Login" onmousedown="login();">
</div>
</fieldset>
</form>
</body>
</html>
Login
<?php
$conn = new mysqli("localhost", "root", "","estore");
session_start();
if (isset($_POST['username'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$query="select name password from signin where name = '$username' and password =
'$password' ";
$result=mysqli_query($conn, $query);
$row=mysqli_fetch_array($result);
if(mysqli_num_rows($result)==1)
{
$_SESSION['user'] = $username;
echo "Login Successful";
} else {
echo "Username and Password is incorrect";
}
}
?>
Output:
Login Form
Confirmation Message
Html code:
inc/dbcon.php
<?php
$server ="localhost";
$user="root";
$password="";
$db="e_learning";
$con=mysqli_connect($server,$user,$password,$db);
if($con){
}
else{
}
?>
inc/style.php
<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
*{
margin:0; padding:0; font-family:'Muli' , sans-serif; box-sizing:border-box;
}
.divider-text{
position: relative;
text-align:center;
margin-top: 15px;
margin-bottom: 15px;
}
.divider-text span{
padding: 7px;
font-size: 12px;
position: relative;
z-index: 2;
}
.divider-text: after{
content:"";
<!DOCTYPE html>
<html>
<head>
<title>Login | E-Learning</title>
<?php include 'inc/style.php' ?>
<?php include 'inc/links.php' ?>
</head>
<body>
<?php
include 'inc/dbcon.php';
if(isset($_POST['submit'])){
$email=$_POST['email'];
$password =$_POST['password'];
<?php
session_start();
if (!isset($_SESSION['username'])) {
header('location:login.php');
exit();
}
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<h1>User Details</h1>
<h4><a href="index.php">Hello!
<?php
include('inc/dbcon.php');
$query=mysqli_query($con,"SELECT * FROM `registeration` WHERE
username='".$_SESSION['username']."'");
$row=mysqli_fetch_array($query);
echo 'Admin '.$row['username'].'';
?>