0% found this document useful (0 votes)
84 views36 pages

Osp Record

The document describes a shell program to calculate the factorial of a positive integer number. It takes the number as input from the user, initializes a variable to store the factorial, and uses a while loop to iteratively multiply the input number with integers from a decreasing counter to calculate the factorial. Finally, it prints the calculated factorial value.

Uploaded by

Vicky 0619
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)
84 views36 pages

Osp Record

The document describes a shell program to calculate the factorial of a positive integer number. It takes the number as input from the user, initializes a variable to store the factorial, and uses a while loop to iteratively multiply the input number with integers from a decreasing counter to calculate the factorial. Finally, it prints the calculated factorial value.

Uploaded by

Vicky 0619
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/ 36

DEPARTMENT OF COMPUTER APPLICATION, SIASC, TIRUVANNAMALAI.

PRG.NO: 01
FRAMES AND TABLES

DATE: 22.12.2023

AIM
To create a simple web page using HTML tags with frames and tables.

PROCEDURE

Step 1: Open a new file using notepad.


Step 2: Create an HTML page named as “frames.html”. Divided the
pageinto two columns of 25%, and 75% size.
Step 3: In 25% display creates an HTML page named as frames.html
describes how a single web page is split in multiple frames.
Step 4: In 75% display divide the page into two rows of 40% and
60% size.
Step 5: Create table Using table’s tags like <th>, <tr>, <td>.
<TABLE BORDER=1>
<TR>
<TH>….</TH>
<TD>….</TD>
</TR>
</TABLE>
Step 6: Run the program using an internet explorer web browser.

DESCRIPTION

HTML
The language used to develop web page is called hyper text markup
language.
HTML tag begin within open angle bracket (<) and end with a close angle
bracket (>).

HEAD
The exception of information contained within the <title>..</title>tags
all information placed within the <head>...</head> tags are not displayed in the
browser.

BODY
The tags used to indicate the start and end of the main body of
textualinformation.
<BODY>…….</BODY>

BGCOLOR
Change of default background bgcolor to whatever color is specified this
tag.
<BODY BGCOLOR=”….”>

OPEN SOURCE SOFTWARE LAB [CPCA67] 1


DEPARTMENT OF COMPUTER APPLICATION, SIASC, TIRUVANNAMALAI.

FRAMES AND TABLES


TAGS

frames.hml

<html>
<head>
<title>SHANMUGA INDUSTRIES ARTS AND SCIENCE
COLLEGE</title>
<frameset rows="25%,75%" cols="*">
<frame src="top.html" />
<frameset cols="25%,75%">
<frame src="left.html" name="fr" />
<frame src="file2.html" name="right" />
</frameset>
</frameset></html>

top.html

<html>
<body>
<link rel="stylesheet" type="text/css" href="sample prgm1.html" />
<body bgcolor="#009900">
<h1><center>SHANMUGA INDUSTRIES ARTS AND SCIENCE
COLLEGE</center>
</h1>
<h2><marquee>ADMISSION OPENS</marquee></h2>
</body></html>

left.html

<html>
<body bgcolor="#FF00CC">
<a href="file1.html" target="right">UG DEGREE</a><br/>
<a href="file2.html" target="right">PG DEGREE</a><br/>
</body></html>

OPEN SOURCE SOFTWARE LAB [CPCA67] 2


DEPARTMENT OF COMPUTER APPLICATION, SIASC, TIRUVANNAMALAI.

file1.html

<html>
<body>
<h4>UG DEGREE</h4>
<table border="1">
<tr>
<th>COURSE</th>
<th>AMOUNT</th>
</tr>
<tr>
<td>BCA</td>
<td>23000</td>
</tr>
<tr>
<td>B.B.A</td>
<td>9000</td>
</tr>
<tr>
<td>B.Com</td>
<td>9000</td>
</tr></table></body></html>

file2.html

<html>
<body>
<h4>PG COURSE</h4>
<table border="1">
<tr>
<th>COURSE</th>
<th>AMOUNT</th>
</tr>
<tr>
<td>M.Com</td>
<td>40000</td>
</tr>
<tr>
<td>M.A.English</td>
<td>20000</td>
</tr>
</tr></table></body></html>

OPEN SOURCE SOFTWARE LAB [CPCA67] 3


DEPARTMENT OF COMPUTER APPLICATION, SIASC, TIRUVANNAMALAI.

OUTPUT

RESULT
Thus the program has been created and executed successfully.

OPEN SOURCE SOFTWARE LAB [CPCA67] 4


DEPARTMENT OF COMPUTER APPLICATION, SIASC, TIRUVANNAMALAI.

PRG.NO: 02
CASCADING STYLE SHEET

DATE: 03.01.2024

AIM
To create a simple web page using HTML tags with cascading style sheet.

PROCEDURE

Step 1: Open a new file using notepad.


Step 2: Save the file as main.html
Step 3: Create a file (External cascading style sheet) by name style.css.
Where font, size, color, etc., are specified the style type
should beset to “text/css” under the <head> tag.
Step 4: The style.css file should be include in main.html file in the link
<a href> tag.

Step 5: In the <body> tag of the html document create an headers using
<h1>, <h2>, and <h3> ordered list using <ol> tag and tables.
Step 6: Run the program using an internet explorer web browser.

DESCRIPTION

HREF
Hyper Text Reference
This attribute prints the link to a book mark, another file either
withinthe same websites or elsewhere on the internet.
<a href=”URL”>
HEADING

<h1>….</h1>
<h2>….</h2>
<h3>….</h3>

OPEN SOURCE SOFTWARE LAB [CPCA67] 5


DEPARTMENT OF COMPUTER APPLICATION, SIASC, TIRUVANNAMALAI.

CASCADING STYLE SHEET


TAGS
Style.css

h3{font-family:arial;font-size:20;color:cyan}
table{border-color:green}
td{font-size:20pt;color:megenta}

main.html

<html>
<head><h1><center>ALL STYLE SHEETS</center></h1><title>CSS</title>
<link rel="stylesheet" href="style.css" type="text/css">
<style type="text/css">
.vid{font-family:verdana;font-style:italic;color:brown;textalign:center;}
.ani{font-family:tohama;font-style:italic;font-size:20;textalign:center;}
font{font-family:georiga;color:blue;font-size:20}
ul{list-style-type:circle}
</style>
</head>
<body>
<ol style="list-style-type:lower-roman">
<b><center>SHANMUGA INDUSTRIES ARTS & SCIENCE
COLLEGE,</center><center>TIRUVANNAMALAI.</center><b>
<br><br><br>
<li>Department of Computer Application</li>
<li>Department of Computer science</li>
<li>Department of Mathematics</li>
<li>Department of Physics</li>
<li>Department of English</li>
</ol>
<p style="font-size:20pt;color:purple"></p>
<p class="ani">SHANMUGA INDUSTRIES ARTS & SCIENCE
COLLEGE,<br>MANALURPET ROAD,TIRUVANNAMALAI. <br> (Affilicated to
Thiruvalluvar University,Vellore)<br></p>
<h2 class="vid">Self Financing College</h2><br>
<font><h2>List of Courses Offered</h2>
<ul>
<li>B.A(English)</li>
<li>B.Com(General)</li>
<li>B.Sc(Mathametics)</li>
<li>B.Sc(Computer Science)</li>
<li>BCA</li>
<li>BBA</li>
<li>B.Com(Computer Application)</li>
<li>M.Sc(Mathametics)</li>
<li>M.A(English)</li>
</font>
<h3>RESULT OF BCA STUDENT</h3>

OPEN SOURCE SOFTWARE LAB [CPCA67] 6


DEPARTMENT OF COMPUTER APPLICATION, SIASC, TIRUVANNAMALAI.

<table width="100%" cellspacing="2" cellpadding="2" border="5">


<tr>
<th>Name</th>
<th>Mark</th>
<th>Results</th>
</tr>
<td align="center">Sana</td>
<td align="center">100</td>
<td align="center">Pass</td>
</tr>
<tr>
<td align="center">Selvam</td>
<td align="center">99</td>
<td align="center">Pass</td>
</tr>
<tr>
<td align="center">sathish</td>
<td align="center">98</td>
<td align="center">Pass</td>
</tr>
</table>
</body>
</html>

OPEN SOURCE SOFTWARE LAB [CPCA67] 7


DEPARTMENT OF COMPUTER APPLICATION, SIASC, TIRUVANNAMALAI.

OUTPUT

RESULT
Thus the program has been created and executed successfully.

OPEN SOURCE SOFTWARE LAB [CPCA67] 8


DEPARTMENT OF COMPUTER APPLICATION, SIASC, TIRUVANNAMALAI.

PRG.NO: 03
FACTORIAL OF AN INTEGER POSITIVE NUMBER

DATE: 11.01.2024

AIM
To write a shell program to find the factorial of an integer
Positive number.

PROCEDURE

Step 1: Using basic command to crate the state program.


Step 2: Read the value.
Step 3: Declared the integer value to find the factorial.
Step 4: Express the factorial formula.
Step 5: Increment to values.
Step 6: Print the factorial values.
Step 7: Show the output data read and run.

OPEN SOURCE SOFTWARE LAB [CPCA67] 9


DEPARTMENT OF COMPUTER APPLICATION, SIASC, TIRUVANNAMALAI.

FACTORIAL OF AN INTEGER POSITIVE NUMBER

CODING

clear
echo “Enter n value”
read n
f=1
while [ $n -gt 1 ]
do
f= $((f*n))
n= $((n-1))
done
echo “The factorial is $f”

OUTPUT

RESULT
Thus the program has been created and executed successfully.

OPEN SOURCE SOFTWARE LAB [CPCA67] 10


DEPARTMENT OF COMPUTER APPLICATION, SIASC, TIRUVANNAMALAI.

PRG.NO: 04
DETAILS OF A USER SESSION

DATE: 24.01.2024

AIM

To write a shell program for details of a user session.

PROCEDURE

Step 1: Create the shell program for details of a user session.


Step 2: Read/ Get the string.
Step 3: Declare the number.
Step 4: Count the number of users and print.
Step 5: Using logged-in user.
Step 6: Check the groups.
Step 7: Get show the user session.

OPEN SOURCE SOFTWARE LAB [CPCA67] 11


DEPARTMENT OF COMPUTER APPLICATION, SIASC, TIRUVANNAMALAI.

DETAILS OF A USER SESSION

CODING

echo –e”\n USER SESSION DETAILS


1. For counting the number of logged-in user

2. For the currently of logged-in users

3. For checking the groups to which the current user belong”

read input
case $input in
1)

who –count | greb user #syntax who <option><user optional>&grep used to filter
;;
2)
who –q | grep –v users #-q or –count option is to count the number of
users andprint the logged-in users.

;;
3)

groups #syntax groups<option>[USERNAME]


;;
*)
echo –e”Please Enter Correct Input\n”
;;
easc

OPEN SOURCE SOFTWARE LAB [CPCA67] 12


DEPARTMENT OF COMPUTER APPLICATION, SIASC, TIRUVANNAMALAI.

OUTPUT

RESULT
Thus the program has been created and executed successfully.

OPEN SOURCE SOFTWARE LAB [CPCA67] 13


DEPARTMENT OF COMPUTER APPLICATION, SIASC, TIRUVANNAMALAI.

PRG.NO: 05
SIMPLE CALCULATOR IN JAVASCRIPT

DATE: 29.01.2024

AIM
To create a simple calculator in Java Scrip using form and table.

PROCEDURE

Step 1: Enter the program in the text editor.


Step 2: Specify the form.
Step 3: Create the input box <input type=”text” Name=”Input” size=20>.
Step 4: Create the button on to enter into the calculator
<input type=”button” Name=”one” value=”1” onclick=”form name”
outputvalue+=”1”>
Step 5: In order to calculator the value use the method the value as
methodeval(form name, input values).
Step 6: Run the program using the internet explorer web browser.

DESCRIPTION
FORM
HTML forms can be made up of a variety of html elements that user input the
<form>. ..</form> tag.
TEXT
A text field (<input type="text"
BUTTON
A new element that provides a button other that a submit reset button.
<input type=button">
METHOD NAME

ONCLICK()
Files when an object is clicked on write equal().

EVAL()
The eval of function can be used to convert a string expression to a
numeric value.

OPEN SOURCE SOFTWARE LAB [CPCA67] 14


DEPARTMENT OF COMPUTER APPLICATION, SIASC, TIRUVANNAMALAI.

SIMPLE CALCULATOR IN JAVASCRIPT

TAGS

<html>
<head><title>calculator</title>
<script language="javascript">
varinputstring=" "
functionupdatestring(value)
{
inputstring+=value;
document.calculator.input.value=inputstring;
}
</script> </head>
<body bgcolor="green">
<form name="calc">
<table border=10 border color="black">
<tr><td>
<input type="text"name="input"size="18">
<br></td></tr>
<tr><td>
<input type="button" name="one" value="1" onclick="calc.input.value+='1'">
<input type="button" name="two" value="2" onclick="calc.input.value+='2'">
<input type="button" name="three" value="3" onclick="calc.input.value+='3'">
<input type="button" name="plus" value="+" onclick="calc.input.value+='+'"><br>
<input type="button" name="four" value="4" onclick="calc.input.value+='4'">
<input type="button" name="five" value="5" onclick="calc.input.value+='5'">
<input type="button" name="six" value="6" onclick="calc.input.value+='6'">
<input type="button" name="minus" value="-" onclick="calc.input.value+='-'"><br>
<input type="button" name="seven" value="7" onclick="calc.input.value+='7'">
<input type="button" name="eight"value="8" onclick="calc.input.value+='8'">
<input type="button" name="nine"value="9" onclick="calc.input.value+='9'">
<input type="button" name="mul" value="*" onclick="calc.input.value+='*'"><br>
<input type="button" name="clear" value="c" onclick="calc.input.value=''">
<input type="button" name="zero" value="0" onclick="calc.input.value+='0'">
<input type="button" name="equal" value="="
onclick="calc.input.value=eval(calc.input.value)">
<input type="button" name="div" value="/" onclick="calc.input.value+='/'"><br>
<input type="button" name="dot" value="." onclick="calc.input.value+='.'">
</td></tr></table>
</form>
</body>
</html>

OPEN SOURCE SOFTWARE LAB [CPCA67] 15


DEPARTMENT OF COMPUTER APPLICATION, SIASC, TIRUVANNAMALAI.

OUTPUT

RESULT
Thus the program has been created and executed successfully.

OPEN SOURCE SOFTWARE LAB [CPCA67] 16


DEPARTMENT OF COMPUTER APPLICATION, SIASC, TIRUVANNAMALAI.

PRG.NO: 06
SCROLL YOUR NAME USING JAVA SCRIPT

DATE: 03.02.2024

AIM
To create a program to scroll name using scroll box in Java Script

PROCEDURE

Step 1: Open a new file using notepad.


Step 2: Specify the form.
Step 3: Create the input box
<input type=”text” Name=”YourName” size=20>
<input type=”text” Name=”FavoriteWord” size=20>
Step 4: Run the program using an internet explorer web browser.

DESCRIPTION

STYLE SHEET TAG

<style sheet=”text/css”>
{
.
.
}
</style>

JAVA SCRIPT TAG

<script type=”text/javascript”>
</script>

OPEN SOURCE SOFTWARE LAB [CPCA67] 17


DEPARTMENT OF COMPUTER APPLICATION, SIASC, TIRUVANNAMALAI.

SCROLL YOUR NAME USING JAVA SCRIPT

TAGS

<html>
<head>
<script language="javascript">
document.write('<style type="text/css">');
document.write("#textarea{");
document.write("background-color: #009999;");
document.write("SCROLLBAR-HIGHLIGHT-COLOR: #000099; ");
document.write("SCROLLBAR-SHADOW-COLOR: #3366cc; ");
document.write("SCROLLBAR-ARROW-COLOR: #000099; ");
document.write("SCROLLBAR-TRACK-COLOR: #000099: ");
document.write("SCROLLBAR-DARKSHADOW-COLOR: #000099; ");
document.write("SCROLLBAR-BASE-COLOR: #6699ff; ");
document.write(" }");
document.write("</style>");
</script>
</head>
<body>
<textarea name="textarea" cols="30" rows="10" id="textarea">
Open Source Software
Open Source Software
Open Source Software
Open Source Software
Open Source Software
Open Source Software
Open Source Software
Open Source Software
Open Source Software
Open Source Software
Open Source Software
</textarea>
</body>
</html>
<html>
<head>
<STYLE TYPE="text/css"> BODY {
scrollbar-arrow-color:#F2B3OD; scrollbar-track-color:#FFFFCC; scrollbar-shadow-
color:#FFFFFF;
scrollbar- face-color:#FFFFCC;
scrollbar-darkshadow-color:#F2B3OD; scrollbar-3dlight-color:#F2B30D;
}
</STYLE>
</head>
</html>

OPEN SOURCE SOFTWARE LAB [CPCA67] 18


DEPARTMENT OF COMPUTER APPLICATION, SIASC, TIRUVANNAMALAI.

OUTPUT

RESULT
Thus the program has been created and executed successfully.

OPEN SOURCE SOFTWARE LAB [CPCA67] 19


DEPARTMENT OF COMPUTER APPLICATION, SIASC, TIRUVANNAMALAI.

PRG.NO: 07
CHECK MESSAGE PASSING SYSTEM
BETWEEN PAGES
DATE: 05.02.2024

AIM

To develop a program and check message passing mechanism betweenpages.

PROCEDURE

Step 1: Open a new file using notepad.


Step 2: Get the input form the text box using HTML tags.
Step 3: Design the message passing using PHP code.
Step 4: Check the message whether the message passing or not.
Step 5: Run the program using an internet explorer web browser.
Step 6: Request your prgm7.html in ex7.php
Step 7: Display the message passing using PHP code.
Step 8: Show the passing mechanism.

OPEN SOURCE SOFTWARE LAB [CPCA67] 20


DEPARTMENT OF COMPUTER APPLICATION, SIASC, TIRUVANNAMALAI.

CHECK MESSAGE PASSING SYSTEM BETWEEN PAGES


TAGS

prgm7.html

<html>
<body>
<form action="ex7.php"
method="post">Name: <br/>
<input type="text"
name="name"/><br/>Color:<br/>
<input type="text" name="Color"/>
<input type="Submit" name ="Submit" value="Submit"/>
</form>
</body>
</html>
ex7.php

<html>
<?php
$Yourname=$_REQUEST['Yourname'];
$Color=$_REQUEST['Color'];
?>
<body bgcolor="skyblue" text="golden">
<p> Hi
<?php
print $Yourname;
?>
<p>
You like the word<b>
<?php
print $Color;
?>
</b>
</body>
</html>

OPEN SOURCE SOFTWARE LAB [CPCA67] 21


DEPARTMENT OF COMPUTER APPLICATION, SIASC, TIRUVANNAMALAI.

OUTPUT

RESULT
Thus the program has been created and executed successfully.

OPEN SOURCE SOFTWARE LAB [CPCA67] 22


DEPARTMENT OF COMPUTER APPLICATION, SIASC, TIRUVANNAMALAI.

PRG.NO: 08
EMAIL REGISTRATION AND LOGIN
USING PHP AND MYSQL
DATE: 12.02.2024

AIM
To create a web application for E-Mail Registration and Login page using PHP and
MYSQL.

PROCEDURE

Step 1: Create database and table in MySql.


Step 2: Open a new file using notepad.
Step 3: Create PHP coding in wamp server.
Step 4: Run the program using an internet explorer web browser.
Step 5: Create registration and login form using register.php
Step 6: Check the MySql table username and password values are stored or not.
Step 7: C h e c k t h e l o g in . p h p , me m b e r . p h p lo g i n i s v a l i d o r n o t .
Step 8: Show the login is successfully created or not.

OPEN SOURCE SOFTWARE LAB [CPCA67] 23


DEPARTMENT OF COMPUTER APPLICATION, SIASC, TIRUVANNAMALAI.

EMAIL REGISTRATION AND LOGIN USING PHP AND MYSQL

DATABASE AND TABLE CREATION

TAGS

register.php

<html>
<head>
<title> Register</title>
</head>
<body>
<center><h1> CREAT REGISTRATION AND LOGIN FORM USING PHP AND
MYSQL</h1></center>
<p> <a href="register.php">Register</a>|<a href="login.php"> Login</a></p>
<center><h2> Registration Form</h2></center>
<form action="" method="POST">
Username:<input type="text" name="user"><br/><br/>
Password:<input type="password" name="pass"><br/>
<input type="submit" value="Register"name="submit"/>
</form>
<?php

OPEN SOURCE SOFTWARE LAB [CPCA67] 24


DEPARTMENT OF COMPUTER APPLICATION, SIASC, TIRUVANNAMALAI.

if(isset($_POST["submit"]))
{
if(!empty($_POST['user']) && !empty($_POST['pass']))
{
$user=$_POST['user'];
$pass=$_POST['pass'];
$con=mysql_connect('localhost','root','') or die(mysql_error());
mysql_select_db('log_details') or die("cannot select DB");
$query=mysql_query("SELECT * FROM login WHERE username='".$user."'");
$numrows=mysql_num_rows($query);
if($numrows==0)
{
$sql="insert into login(username,password)values('$user','$pass')";
$result=mysql_query($sql);
if($result)
{
echo "Account Successfully Created";
}
else
{
echo "Failure!";
}
}
else
{
echo "That username already exist! Please try again with another..";
}
}
else
{
echo "All Fields are required";
}
}
?>
</body>
</html>

login.php

<html>
<head>
<title> Login </title>
<body>
<center><h1> CREATE REGISTRATION AND LOGIN FORM USING PHP AND MYSQL
</h1> </center>
OPEN SOURCE SOFTWARE LAB [CPCA67] 25
DEPARTMENT OF COMPUTER APPLICATION, SIASC, TIRUVANNAMALAI.
<p><a href="register.php"> Register</a> | <a href="login.php"> Login</a></p>
<h3> Login Form</h3>
<form action=""method="POST">
Username:<input type="text" name="user"><br/><br/>
Password:<input type="password" name="pass"><hr/>
<input type="submit"value="Login"name="submit"/>
</form>
<?php
if(isset($_POST["submit"]))
{
if(!empty($_POST['user']) && !empty($_POST['pass']))
{
$user=$_POST['user'];
$pass=$_POST['pass'];
$con=mysql_connect('localhost','root','') or die(mysql_error());
mysql_select_db('log_details') or die("cannot select DB");
$query=mysql_query("SELECT * FROM login WHERE username='".$user."' AND
password='".$pass."'");
$numrows=mysql_num_rows($query);
if($numrows!=0)
{
while($row=mysql_fetch_assoc($query))
{
$dbusername=$row['username'];
$dbpassword=$row['password'];
}
if($user==$dbusername && $pass==$dbpassword)
{
session_start();
$_SESSION['sess_user']=$user;
header("Location:member.php");
}
}
else
{
echo "Invalid username or password!";
}
}
else
{
echo "All fields are required!";
}
}
?>
</body>
</html>
OPEN SOURCE SOFTWARE LAB [CPCA67] 26
DEPARTMENT OF COMPUTER APPLICATION, SIASC, TIRUVANNAMALAI.

member.php

<?php
session_start();
if(!isset($_SESSION["sess_user"]))
{
header("location:login.php");
}
else
{
?>
<html>
<head>
<title> Welcome</title>
</head>
<body>
<center><h1>CREATE REGISTRATION AND LOGIN FORM USING PHP AND
MYSQL</h1></center>
<h2> welcome, <?=$_SESSION['sess_user'];?>! <a href="logout.php">Logout</a></h2>
<p>
WE DO IT. SUCCESSFULLY CREATED REGISTRATION AND LOGIN FORM USING
PHP AND MYSQL..
</P>
</body>
</html>
<?php
}
?>

logout.php

<?php
session_start();
unset($_SESSION['sess_user']);
session_destroy();
header("location:login.php");
?>

OPEN SOURCE SOFTWARE LAB [CPCA67] 27


DEPARTMENT OF COMPUTER APPLICATION, SIASC, TIRUVANNAMALAI.

OUTPUT

OPEN SOURCE SOFTWARE LAB [CPCA67] 28


DEPARTMENT OF COMPUTER APPLICATION, SIASC, TIRUVANNAMALAI.

RESULT
Thus the program has been created and executed successfully.

OPEN SOURCE SOFTWARE LAB [CPCA67] 29


DEPARTMENT OF COMPUTER APPLICATION, SIASC, TIRUVANNAMALAI.

PRG.NO: 09
CREATE A FILE AND WRITE THE DATA
INTO IT USING PHP USING PHP
DATE: 13.02.2024

AIM
To create a file and write the data in to the file using PHP.

PROCEDURE

Step 1: This PHP script that allows a user to create and write to a file, as well
as read from the file
Step 2: It creates an HTML form with two submit buttons: "write File" and
"readFile".
Step 3: The form has a single text input field named "name" where the user
can enter a string.
Step 4: When the user clicks the "write File" button, the PHP script creates
a new file named "abc.txt" (if it doesn't already exist) and opens it for
writing with the "a" mode (appending to the end of the file).
Step 5: It then retrieves the text input from the form using the $_POST
superglobal variable and writes it to the file using the fwrite()
function.
Step 6: When the user clicks the "read File" button, the PHP script opens the
"abc.txt" file in read mode ("r"), retrieves the contents of the file using
thefgets() function, and prints it to the screen using the echo
statement.
Step 7: Finally, it closes the file handle using fclose().

OPEN SOURCE SOFTWARE LAB [CPCA67] 30


DEPARTMENT OF COMPUTER APPLICATION, SIASC, TIRUVANNAMALAI.

CREATE A FILE AND WRITE THE DATA INTO IT USING PHP

TAGS

exp9.php

<html>
<head>
<title> PHP FILE CREATE AND WRITE THE DATA INTO IT USING PHP </title>
</head>
<body>
<form method= "POST">
<h3> Reading and Writing a file </h3>
Enter String: <input type="text" name="name"><br/><br/>
<input type="submit" name="Submit1" value="Write File">
<input type="submit" name="Submit2" value="Read File">
</form>
<?php
if(isset($_POST['Submit1']))
{
$myfile=fopen("abc.txt","a");
$text=$_POST["name"];
fwrite($myfile,$text);
fclose($myfile);
}
if(isset($_POST['Submit2']))
{
$myfile=fopen("abc.txt","r");
echo fgets($myfile);
fclose($myfile);
}
?>
</body>
</html>

OPEN SOURCE SOFTWARE LAB [CPCA67] 31


DEPARTMENT OF COMPUTER APPLICATION, SIASC, TIRUVANNAMALAI.

OUTPUT

Write a file

Read a file

OPEN SOURCE SOFTWARE LAB [CPCA67] 32


DEPARTMENT OF COMPUTER APPLICATION, SIASC, TIRUVANNAMALAI.

Now file “abc.txt” created in www folder

RESULT
Thus the program has been created and executed successfully.

OPEN SOURCE SOFTWARE LAB [CPCA67] 33


DEPARTMENT OF COMPUTER APPLICATION, SIASC, TIRUVANNAMALAI.

PRG.NO: 10
PERFORM THE STRING OPERATION USING PERL

DATE: 17.02.2024

AIM
To create a program and perform the string operations using perl.

PROCEDURE

Step 1: Open a text editor such as Notepad, Notepad++, or Sublime Text.


Step 2: Type my Perl code in the text editor.
Step 3: Save the file with a .pl extension, for example, string.pl.
Step 4: Open a terminal or command prompt on my computer.
Step 5: Navigate to the directory where I saved the Perl script using the
cd command. For example, if I saved the script in the Documents
folder, I can use the command cd Documents.
Step 6: Run the Perl script using the perl command followed by the name of the
script. For example, I can run the script s t r i n g .pl using the
command perl string.pl.

OPEN SOURCE SOFTWARE LAB [CPCA67] 34


DEPARTMENT OF COMPUTER APPLICATION, SIASC, TIRUVANNAMALAI.

PERFORM THE STRING OPERATION USING PERL


CODING

Sring.pl

#Declaration and Initialization


my $study="I am studying in BCA";
my $college="Shanmuga Industries Arts & Science College";
print"\nDeclaration and Initialization:$study at $college\n\n";

#interpolation-Single vs double quotes


print "Interpolation : Double Quotes - Welcome to \t Open Souce Software Lab\n";
print 'Interpolation : Single Quotes - Welcome to \t Open Souce Software Lab\n';

#Concatenate
my $string1="Raman";
my $string2="Sita";
my $constr=$string1.$string2;
print"\n\nConcatenate String:$constr";

#Repetition
my $repstr="$string1"x 6;
print"\n\nRepentition:$repstr\n\n";

#This is our original string


my $str="\nOpen source Software is code that is designed to be publicly accessible";
print "My original String is:$str\n";

#substring-starting from 38th char till the end of string


my $substr1=substr($str,37);
print "\n\nMy First subsring is:$substr1\n";

#substring-string from 38th char and length of 11


my $substr2=substr($str,38,11);
print "\n\nMy Second subsring is:$substr2\n";

#length() function
print "\n\nlength of my string is:",length($str);

#String comparsion in Perl


my $str1="hello";
my $str2="Hello";
if($str1 eq $str2)
{
print "\n\nstr1 and $str2 are same\n";
}
else
{
print "\n\n$str1 and $str2 is not same\n";
}

OPEN SOURCE SOFTWARE LAB [CPCA67] 35


DEPARTMENT OF COMPUTER APPLICATION, SIASC, TIRUVANNAMALAI.

OUTPUT

RESULT
Thus the program has been created and executed successfully.

OPEN SOURCE SOFTWARE LAB [CPCA67] 36

You might also like