Skip to content

Commit

Permalink
all tybca practical programs
Browse files Browse the repository at this point in the history
  • Loading branch information
Agniprastha authored Oct 20, 2018
1 parent e8af320 commit 47ffb7b
Show file tree
Hide file tree
Showing 82 changed files with 2,946 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ty_Bca_Php_program/AS6_session/6a3.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
/*Write a script to keep track of number of times the web page has been accessed using session.
*/
if(isset($_COOKIE['accesses']))
$cnt = $_COOKIE['accesses'];
else
$cnt = 0 ;
setcookie('accesses', ++$cnt);
echo "You have visited this page $cnt times ";
?>
18 changes: 18 additions & 0 deletions ty_Bca_Php_program/AS6_session/6a4.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

<html>
<!
Create a login form with a username and password. Once the user logs in, the second form
should be displayed to accept user details (name, city, phoneno). If the user doesn’t enter
information within a specified time limit, expire his session and give a warning otherwise
Display Details using sessions.
!>

<form method="POST" action="login.php" >
<p>User Name: <input type="text" name="user"><br>
<p>Password :<input type="password"><br><br>
<input type="submit" value="Login"><br>
</form>
</html>



14 changes: 14 additions & 0 deletions ty_Bca_Php_program/AS6_session/6b2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<html>
<body>
<form action="01.php" method="post">
<h2>Enter Students information :</h2>
<table>
<tr><td>Name : </td><td><input type="text" name="name"></td><tr>
<tr><td>Address : </td><td><input type="text" name="addr"></td></tr>
<tr><td>Class : </td><td><input type="text" name="class"></td></tr>
<tr><td></td><td><input type="submit" value=Next></td></tr>
</table>
</form>
</body>
</html>

15 changes: 15 additions & 0 deletions ty_Bca_Php_program/AS6_session/6b3.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<html>
<body>
<form action="131.php" method="get">
<center>
<b>Select font style :</b><input type=text name=s1> <br>
<b>Enter font size : </b><input type=text name=s><br>
<b>Enter font color : </b><input type=text name=c><br>
<b>Enter background color :</b> <input type=text name=b><br>
<input type=submit value="Next">
</center>
</form>
</body>
</html>


12 changes: 12 additions & 0 deletions ty_Bca_Php_program/AS6_session/ass6a1.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
A1. A web application that lists all cookies stored in the browser on clicking “list cookies” button,
add cookies if necessary.

<?php

if(isset($_COOKIE['accesses']))
$cnt = $_COOKIE['accesses'];
else
$cnt = 0 ;
setcookie('accesses', ++$cnt);
echo "You have visited this page $cnt times ";
?>
17 changes: 17 additions & 0 deletions ty_Bca_Php_program/AS6_session/ass6a2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
A2. Write a PHP program to store current date-time in a COOKIE and display the ‘Last visited on’
date-time on the web page upon reopening of the same page.

<?php
if(isset($_COOKIE['datee']))
{
$cookieData = $_COOKIE['datee'];
}
$today = getdate();
$d = $today['mday'];
$m = $today['mon'];
$y = $today['year'];
$datestring = "$d - $m - $y";
setcookie("datee", $datestring);
echo "Last visited on date-time:- $cookieData";
?>

29 changes: 29 additions & 0 deletions ty_Bca_Php_program/AS6_session/ass6a4.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
A4. Create a login form with a username and password. Once the user logs in, the second form
should be displayed to accept user details (name, city, phoneno). If the user doesn’t enter
information within a specified time limit, expire his session and give a warning otherwise
Display Details using sessions.
<html>
<body>
<form action="ass6a_4.php" method=get>
<input type='hidden' name='etime' value="<?php echo $t?>">
Enter Name : <input type=textbox name=uname> <br>
Enter City : <input type=textbox name=city><br>
Enter Phone No :<input type=textbox name=pno><br>
<input type=submit name=submit value=DISPLAY>
</form>
</body>
</html>


<?php
session_start();
$t=date("1,d-m-y h:i:s",time()+20);

$_SESSION['etime']=$t;
if(isset($_REQUEST['name']))
//if(isset $_REQUEST['pwd']))
{
echo "Invalid Username Or Password";
}
?>

16 changes: 16 additions & 0 deletions ty_Bca_Php_program/AS6_session/display.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
$pno=$_GET['pno'];
$name=$_GET['name'];
$premium=$_GET['premium'];
if(isset($_COOKIE['ename'])&&isset($_COOKIE['address'])&&isset($_COOKIE['mobile']))
{
echo"<br><b>Employee Details </b><br>";
echo"Employee Name : ".$_COOKIE['ename']." <br>";
echo"Employee Address :".$_COOKIE['address']."<br>";
echo"Mobile No. : ".$_COOKIE['mobile']."<br>";
echo"<br><b>LIC Policy Details</b><br>";
echo"Policy No. : $pno<br>";
echo"Policy Name : $name<br>";
echo"Premium : $premium";
}
?>
37 changes: 37 additions & 0 deletions ty_Bca_Php_program/as2_inhert/ass2a2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Q..Define an interface which has methods area( ), volume( ). Define constant PI. Create a class
cylinder which implements this interface and calculate area and volume.



<?php
interface Cyl
{
function area();
function volume();
}
class Cylinder implements Cyl
{
public $PI=3.14;
public $a;
public $r;
public $h;
function __construct($r,$h)
{
$this->r=$r;
$this->h=$h;
}
function area()
{
$this->a=2*$this->PI*($this->h*$this->r);
echo"Area of Cylinder= ".$this->a."<br>";
}
function volume()
{
$this->a=$this->PI*$this->r*$this->r*$this->h;
echo"Volume of Cylinder= ".$this->a."<br>";
}
}
$c=new Cylinder(10,7);
$c->area();
$c->volume();
?>
41 changes: 41 additions & 0 deletions ty_Bca_Php_program/as2_inhert/ass2a3.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Q..Write a PHP script to demonstrate the introspection for examining class .(use function
et_declared_classes() ,get_class_methods() and get_class_vars()).




<?php
class intro
{
var $i;
function f1()
{

}
function f2()
{

}
}
class intro_1 extends intro
{
var $j,$k;
function f3()
{

}
function f4()
{

}
}
$ob=new intro_1();
echo class_exists('intro');
var_dump(get_declared_classes());
var_dump(get_class_methods('intro_1'));
var_dump(get_class_methods('Exception'));
var_dump(get_class_vars('intro_1'));
var_dump(get_parent_class('intro_1'));
var_dump(get_object_vars($ob));
?>

40 changes: 40 additions & 0 deletions ty_Bca_Php_program/as2_inhert/ass2a4.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Q...Write PHP script to demonstrate the concept of introspection for examining object.



<?php
class introspection
{
var $i;
function f1()
{

}
function f2()
{

}
}
class introspection1 extends introspection
{
var $j,$k;
function f3()
{

}
function f4()
{

}
}
$ob=new introspection1();
if(is_object($ob))
{
echo get_class($ob);
}
if(method_exists($ob,'f4'))
{
echo "method f4 exists";
}
var_dump(get_object_vars($ob));
?>
60 changes: 60 additions & 0 deletions ty_Bca_Php_program/as2_inhert/ass2b1
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@

<?php
/*b1.Create class rectangle and derive a class square from class Rectangle. Create another class
circle. Create an interface with only one method called area(). Implement this interface in all
the classes. Include appropriate data members and constructors in all classes. W rite a program
to accept details of a square, circle and rectangle and display the area.*/
interfce Car
{
public function setmodel($name);
public function getmodel();
}
class miniCar implements Car
{
private $model;

public function setModel($name)
{
$this -> model = $name;
}

public function getModel()
{
return $this -> model;
}
}
interface Vehicle
{
public function setHasWheels($bool);

public function getHasWheels();
}

class miniCar implements Car, Vehicle
{
private $model;
private $hasWheels;

public function setModel($name)
{
$this -> model = $name;
}

public function getModel()
{
return $this -> model;
}

public function setHasWheels($bool)
{
$this -> hasWheels = $bool;
}

public function getHasWheels()
{
return ($this -> hasWheels)? "has wheels" : "no wheels";
}
}
minicar $m=new minicar();
$m->setmodel("ram");
?>
64 changes: 64 additions & 0 deletions ty_Bca_Php_program/as2_inhert/ass2b1.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

interface findarea
{
function area();
}

class rectangle implements findarea
{
public $ln;
public $b;
public function __construct($l,$c)
{
$this->ln=$l;
$this->b=$c;
}
function area()
{
$area = $this->ln*$this->b;
echo "Area of Rectanle :".$area."<br>";
}
}

class square extends rectangle
{
public $si;
public function __construct($s)
{
$this->si=$s;
}
function area()
{
$area = $this->si*$this->si;
echo "Area of Square :". $area."<br>";
}
}

class circle
{
public $ra;
public function __construct($r)
{
$this->ra=$r;
}
function area()
{
$area = 0.5*$this->ra*$this->ra;
echo "Area of Circle :". $area."<br>";
}
}

$fr = new rectangle(3,2);
$fr->area();

$fs = new square(5);
$fs->area();

$fc = new circle(6);
$fc->area()
?>




Loading

0 comments on commit 47ffb7b

Please sign in to comment.