




















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
lab Practical programs for bachelor of computer applications
Typology: Study notes
1 / 28
This page cannot be seen from the preview
Don't miss anything!





















1. Develop and demonstrate an HTML file that includes PHP script to generate first ‘n’ Fibonacci numbers
Fibonacci seris
Enter the limit: "; $c=$a+$b; } } ?>
2. Create a PHP script that accepts a number through inputbox and checks whether it is palindrome or not
Palindrom
Enter the number: php if(isset($_POST['sub'])) { $x=$_POST['n']; $r=0; $z=$x; while($x!=0) { $t=$x%10; $r=$r*10+$t; $x=intval($x/10); } if($z==$r) {
$len=strlen($string);
$num=0; for($i=0;$i<$len;$i++) { if(in_array($string[$i],$vowels)) { $num++; } } echo "Number of vowels: $num"; $len=$len-1; echo "Number of characters: $len"; $word=str_word_count($string); echo "Number of words: $word"; $line=substr_count($_POST['str'],"\n"); echo "Number of lines: $line"; } ?>
4. Develop a simple calculator web application that takes 2 numbers and an operator (+,-,, /,%) from an HTML page and returns the result.*
simple calculator
Enter the number:
Enter another number:
php if(isset($_POST['sub'])) { $num1=$_POST['num1']; $num2=$_POST['num2']; $fun=$_POST['fun']; if(is_numeric($num1) && is_numeric($num2)) { if($fun!=null) { switch($fun) { case "+":
Username:
session started at".date("h:i:sa",$tm).""; echo ""; echo "
"; echo ""; echo "Hello".$_SESSION['luser']; } ?>php
session_start();
date_default_timezone_set("Asia/Calcutta"); echo "
session started at".date("h:i:sa",time())."
"; echo "Thank you ".$_SESSION['luser'].""; $session_time=time()-$_SESSION['start']; echo "Session duration ".$session_time." seconds"; ?>6. Develop a web application that takes the name and age from an HTML page. If the age is less than 18, it should display a page with “hello , you are not authorized to visit this site” otherwise it should display the message, “, welcome to this site”.
Name: Age:
else
{ $_SESSION['counter']=1; } echo "You have visited the page ".$_SESSION['counter']." time in this session"; ?>
8. Develop a database based web application that performs login validation and prints the corresponding message based on checking the username and password from MySQL database.
User Login
Username : Password :
php if(isset($_POST['sub'])) { $conn=new mysqli('localhost','root','','info');
if($conn->connect_errno)
{ echo "Failed to connect with the server"; exit(); } else { $uname=$_POST['uname']; $pass=$_POST['pass']; $q="select Message from users where Username='$uname' and Password='$pass'"; $result=$conn->query($q); if($result->num_rows>0) { $row=$result->fetch_assoc(); echo "Message ".$row['Message']; } else { echo "Either username or password is wrong"; } } } ?>
else
{ echo "Cookie is not set. You have to set cookie"; } ?>
10. Create a PHP script that reads an array and displays the array in sorted order.
Sorting an array
Enter the string:
php if(isset($_POST['sub'])) { $string=$_POST['str']; $x=strlen($string); $count=substr_count($string," "); $array=explode(" ",$string); for($i=0;$i<$count;$i++) { for($j=$i+1;$j<=$count;$j++)
if($array[$i]>$array[$j]) { $temp=$array[$i]; $array[$i]=$array[$j]; $array[$j]=$temp; } } } print_r($array); } ?>
11. Develop a web application that develops a student registration form and displays the entered details to another page
Student Registration Form
Name
Student Details
Name
Age
Gender
Date of Birth
course
Phone no
12. Create a MySQL table containing a few details of employees. Create a PHP web application that can save the employee data given through HTML forms and can fetch and display the table contents into an HTML table.
Employee details
Employee department
Employee Name
$q="insert into empdet(dept,name,id,sal)values
('$edept','$ename','$eid','$esal')"; if($conn->query($q)===TRUE) { echo ""; } else die('error'); } ?>
Employee Details
Employee Department Employee Name Employee id Employee salary
connect_errno)
echo "Failed to connect with the server"; exit(); } $query="select * from empdet"; if($result=$conn->query($query)) { while($row=$result->fetch_assoc()) { echo ""; echo "".$row['dept'].""; echo "".$row['name'].""; echo "".$row['id'].""; echo "".$row['sal'].""; echo ""; } } $conn->close(); ?>
13. Create a database application in PHP that can delete a student record on accepting the enrolment number of the student. A message should be displayed on deletion of the record and the contents of the table should be displayed