[go: up one dir, main page]

0% found this document useful (0 votes)
3 views34 pages

oss correct format

The document contains multiple programming examples in HTML, CSS, JavaScript, PHP, and Perl. It includes creating web pages with frames and tables, implementing CSS styles, writing shell scripts for factorial calculation, and developing a simple calculator in JavaScript. Additionally, it covers user registration and login systems using PHP and MySQL, file creation in PHP, and string operations in Perl.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views34 pages

oss correct format

The document contains multiple programming examples in HTML, CSS, JavaScript, PHP, and Perl. It includes creating web pages with frames and tables, implementing CSS styles, writing shell scripts for factorial calculation, and developing a simple calculator in JavaScript. Additionally, it covers user registration and login systems using PHP and MySQL, file creation in PHP, and string operations in Perl.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

1. Create a web page with Frames and Tables.

Program

Home.html
<html>
<head>
<title> home</title>
</head>
<frameset rows="25%,*">
<frame src="frame1.html" >
<frameset cols="25%,75%">
<frame src="main.html" name="frame2" >
<frame src="click.html" name="frame3" >
</frameset>
</html>

Frame1.html
<html>

<head>

<title> frame1</title>

</head>

<body bgcolor="blue">

<h1 style="color.green;font-size:15pt">

<marquee bgcolor="#cccccc" loop="-1" scrollamount="6" width="100%">

IMMACULATE COLLEGE FOR WOMEN CUDDALORE

</marquee>
</h1>

</body>

</html>

Click.html
<html>
<head>
<title>welcome</title>
</head>
<body bgcolor="black">
<font color=red>
<p>welcome to immaculate college </p>
location:cuddalore<br>
contact no:04142-221444<br>
website:www.imcw.in<br>
</font>
</body>
</html>

Main.html
<html>
<head>
<title>mainframe</title>
</head>
<body bgcolor="red">
<h3>
<a href="table.html"target="frame3">student details</a><br>
<a href="click.html"target="frame3">college details</a><br>
</h3>
</body>
</html>

Table.html
<html>
<head>
<title> table</title>
</head>
<body bgcolor="black">
<h1> student details</h1>
<table border="6" width="60%" align="center" bgcolor="cyan" border
color="red">
<tr>
<th>regno</th>
<th>name</th>
<th>oss</th>
<th>cc</th>
<th>rank</th>
</tr>
<tr>
<td>101</td>
<th>priya</td>
<th>90</td>
<th>90</td>
<th>I</td>
</tr>
<tr>
<td>102</td>
<th>kavya</td>
<th>80</td>
<th>70</td>
<th>I</td>
</tr>
<tr>
<td>103</td>
<th>sneha</td>
<th>90</td>
<th>80</td>
<th>I</td>
</tr>
</table>
</body>
</html>
Output
2. Create a web page incorporating CSS (Cascading Style Sheets)

Program
Dynamic.html
<html>
<head>
<title>HTML using CSS</title>
<link rel="stylesheet" href="mystyle.css" type="text/css">
</head>
<body pgcolor="lavender">>
<center>
<h1>IMMACULATE COLLEGE FOR WOMEN<br>
cuddalore<br>
</h1>
<h2>
Available courses<br>
</h2>
<h3>
Course offered<br>
UG Courses:
</h3>
<ul type="circle">
<li> B.sc computer science
<li> B.sc computer Application
<li> B.sc Maths
<li> B.sc Botany
<li> BA English
<li> BA tamil
<li> Bcom computer science
<li> Bcom computer Application
</ul>
<h3>PG Courses</h3>
<ul type="square">
<li> M.sc computer science
<li> M.sc computer Application
<li> M.sc Maths
<li> M.sc Botany
<li> MA English
<li> MA tamil
<li> Mcom computer science
<li> Mcom computer Application
</ul>
</body>
</html>

Mystyle.css

body
{
background-image:url("san1.jpg");
}
h1
{
color:maroon;
font-family:arial;
text-decoration:underline;
}
h2
{
color:blue;
font-family:times new roman;
text-decoration:underline;
}
h3
{
color:green;
font-family:algerian;
text-decoration:italic;
}
li
{
color:red;
}
ul
{
list-style: square inside url("san.gif");
}
Output
3. Write a shell program to find the factorial of an integer positive number

Program

clear

echo "Enter a Positive Number"

read n

f=1

until [ $n -lt 1 ]

do

f=` expr $f \* $n `

n=` expr $n - 1`

done

echo "Factorial is $f "


Output

Enter a positive number: 6

Factorial of 6 is : 720
4. Write a shell program to find the details of a user session
Program
#!/bin/bash
#here we are you going to develop a script for various options on user
accounts
echo -e "\n
[ 1 ] for listing all the user accounts name \n
[ 2 ] for counting the number of logged-in user accounts \n
[ 3 ] for listing the names of currently logged-in users\n
[ 4 ] for checking the groups to which the current user belong \n"
#Now take user input
read userInput
#Now we will use switch cases for various input operations
case $userInput in
1)
#syntax lslogins <option[=output field]>
lslogins -o USER
;;
2)
#syntax who <option> <user optional>
#grep used to filter
who --count | grep users
;;
3)
#-q option is to count the number of users and print the logged-in users.
# instead of -q, --count can also be used.
# -v is used to exclude any pattern
who -q | grep -v users
;;
4)
#syntax groups <option> [USERNAME]
groups
;;
*)
echo -e "Please Enter Correct Input \n"
;;
5. Create a simple calculator in Java script.
Program:

<html>
<head><title>Calculator</title>
<script language="javascript">
var inputstring=" "
function updatestring(value)
{
inputstring += value;
document.calculator.input.value=inputstring;
}
</script>
</head>
<body background=flow-yellow.jpg>
<form name="calculator">
<table border=5 bordercolor=pink bgcolor="#ffffcc"><tr ><td>
<input type="text" name="input" maxlength=15 size=27><br />
<input type="button" value="clear"onclick="input.value=' ';inputstring=' '
">
<input type="button" value=" mod"onclick="updatestring('%')">
<input type="button" value=" * " onclick="updatestring('*')"><br />
<input type="button" value=" 7 " onclick="updatestring('7')">
<input type="button" value=" 8 " onclick="updatestring('8')">
<input type="button" value=" 9 " onclick="updatestring('9')">
<input type="button" value=" / " onclick="updatestring('/')"><br />
<input type="button" value=" 4 " onclick="updatestring('4')">
<input type="button" value=" 5 " onclick="updatestring('5')">
<input type="button" value=" 6 " onclick="updatestring('6')">
<input type="button" value=" - " onclick="updatestring('-')"><br />
<input type="button" value=" 1 " onclick="updatestring('1')">
<input type="button" value=" 2 " onclick="updatestring('2')">
<input type="button" value=" 3 " onclick="updatestring('3')">
<input type="button" value=" + " onclick="updatestring('+')"><br />
<input type="button" value=" 0 " onclick="updatestring('0')">
<input type="button" value=" 00 " onclick="updatestring('00')">
<input type="button" value=" . " onclick="updatestring('.')">
<input type="button" value=" = "
onclick="input.value=eval(inputstring);">
</td>
</tr>
</table>
</form>
</body>
</html>
Output
6. Write a JavaScript program to scroll your name in the scroll bar.

Program:
<html>
<head>
<script language="javascript">
document.write('<style type="text/css">');
document.write("textarea{");
document.write("background-color:yellow;");
document.write("scroll-highlight-color:red;");
document.write("scrollbar-3dlight-color:green;");
document.write("scrollbar-arrow-color:purle;");
document.write("scrollbar-darkshadow-color:teal;");
document.write("scrollbar-face-color:navy;");
document.write("scrollbar-highlight-color:olive;");
document.write("scrollbar-shadow-color:gray;");
document.write("scrollbar-track-color:lime;");
document.write("}");
document.write("</style>");
</script>
</head>
<body bgcolor="lavender">
<center><u><b>JAVA SCRIPT IN SCROLL BAR</b></u></center><br>
<center><textarea id="textarea" rows="10" cols="30">
John cristober
John cristober
John cristober
John cristober
John cristober
John cristober
John cristober
John cristober
John cristober
John cristober
</textarea>
</center>
</body>
</html>
Output
7. Develop a program and check message passing mechanism
between pages

Program

Page1.php

<html>
<head>
<title>Message Passing</title>
</head>
<body>
<center>
<form action=”page2.php” method=”POST”>
My name is:
<br><input type=”text” name =”uname”><br<
My favorite word is:
<br><input type=”text” name =”fword”>
<input type=”submit” name=”submit” value=”send”>
</center>
</form>
</body>
</html>

Page2.php:

<html>
<head>
<title>Message Passing</title>
</head>
<body bgcolor=”voilrt” tect=”blue”>
<h1> <u>MESSAGE PASSING IN PHP </u></h1><br>
<?php
$name=$_POST[‘uname’];
$word=$_POST[‘fword’];
echo “your name is:$name<br>
echo “favourite word is::$word<br>
?>
</body>
</html>
Output
8. APPLICATION FOR EMAIL REGISTRATION AND LOGIN USING
PHP AND MYSQL

PROGRAM

Registeration .php

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8"/>

<title>Registration</title>

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

</head>

<body>

<?php

require('db.php');

// When form submitted, insert values into the database.

if (isset($_REQUEST['username'])) {

// removes backslashes

$username = stripslashes($_REQUEST['username']);

//escapes special characters in a string

$username = mysqli_real_escape_string($con, $username);


$email = stripslashes($_REQUEST['email']);

$email = mysqli_real_escape_string($con, $email);

$password = stripslashes($_REQUEST['password']);

$password = mysqli_real_escape_string($con, $password);

$create_datetime = date("Y-m-d H:i:s");

$query = "INSERT into `users` (username, password, email,


create_datetime)

VALUES ('$username', '" . md5($password) . "', '$email',


'$create_datetime')";

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

if ($result) {

echo "<div class='form'>

<h3>You are registered successfully.</h3><br/>

<p class='link'>Click here to <a


href='login.php'>Login</a></p>

</div>";

} else {

echo "<div class='form'>

<h3>Required fields are missing.</h3><br/>

<p class='link'>Click here to <a


href='registration.php'>registration</a> again.</p>
</div>";

} else {

?>

<form class="form" action="" method="post">

<h1 class="login-title">Registration</h1>

<input type="text" class="login-input" name="username"


placeholder="Username" required />

<input type="text" class="login-input" name="email"


placeholder="Email Adress">

<input type="password" class="login-input" name="password"


placeholder="Password">

<input type="submit" name="submit" value="Register" class="login-


button">

<p class="link"><a href="login.php">Click to Login</a></p>

</form>

<?php

?>

</body>

</html>
Login.php

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8"/>

<title>Login</title>

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

</head>

<body>

<?php

require('db.php');

session_start();

// When form submitted, check and create user session.

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

$username = stripslashes($_REQUEST['username']); // removes


backslashes

$username = mysqli_real_escape_string($con, $username);

$password = stripslashes($_REQUEST['password']);

$password = mysqli_real_escape_string($con, $password);

// Check user is exist in the database


$query = "SELECT * FROM `users` WHERE
username='$username'

AND password='" . md5($password) . "'";

$result = mysqli_query($con, $query) or die(mysql_error());

$rows = mysqli_num_rows($result);

if ($rows == 1) {

$_SESSION['username'] = $username;

// Redirect to user dashboard page

header("Location: dashboard.php");

} else {

echo "<div class='form'>

<h3>Incorrect Username/password.</h3><br/>

<p class='link'>Click here to <a href='login.php'>Login</a>


again.</p>

</div>";

} else {

?>

<form class="form" method="post" name="login">

<h1 class="login-title">Login</h1>
<input type="text" class="login-input" name="username"
placeholder="Username" autofocus="true"/>

<input type="password" class="login-input" name="password"


placeholder="Password"/>

<input type="submit" value="Login" name="submit" class="login-


button"/>

<p class="link"><a href="registration.php">New


Registration</a></p>

</form>

<?php

?>

</body>

</html>
Output
9. Program to create a File and write the Data into it using PHP

Program

<html>
<head>
<title>PHP Script Create a .txt file & write content in it in PHP</title>
</head>
<body>

<h2>Write a PHP program Create a .txt file & write content in it</h2>

<form action="" method="POST">


<textarea name="text" rows="5" cols="40"></textarea><br>
<input type="submit" name="ok"/>
</form>

<?php
if($_POST)
{
$txt = $_POST['text'];

$myfile = fopen("newfile.txt","w");//create a file

if(fwrite($myfile,$txt) === false) //write a file


{
echo "Error in writing!!!";
}
else
{
echo "File Created & Updated Successfully";
}

fclose($myfile);
}
?>

</body>
</html>
Output
10. PROGRAM TO PERFORM THE STRING OPERATION USING PERL.

PROGRAM
#!usr/bin/perl
$a="hello";
$b="world";
print $a.$b,"\n";
$str="-";
print $str x 80,"/n";
@a=(10..25);
print "@a\n";
OUTPUT

output [linuxpert@localhost ~]$ perl string.pl


helloworld
--------------------------------------------------------------------------------/n10 11 12
13 14 15 16 17 18 19 20 21 22 23 24 25

You might also like