Sie sind auf Seite 1von 19

PROGRAM NO : 1

AIM : DATE VALIDATION


DATE : 09/02/2016
________________________________________________________________________________

<html>
<head>
<title>
Program 1
</title>
</head>
<body>
<h3>
Enter the date to validate
</h3>
<form method="post" action="" name="myform">
<input type="text" name="date" placeholder="DD-MM-YYYY"/>
<input type="submit" name="submit" value="submit" class="length"/>
</form>
</body>
</html>
<?php
if(isset($_POST["submit"]))
{
$date=$_POST["date"];
list($day,$month, $year) = split('[/.-]', $date);
if(checkdate($day,$month,$year))
{
echo ' date you entered is correct';
echo "$date";
echo "<script>alert ('date you entered is correct');</script>";
}
else
{
echo 'date you entered is incorrect';
echo "<script>alert('date you entered is incorrect');</script>";
}
}
?>

PROGRAM NO: 2
AIM : DATE FORMATING
DATE : 09/02/2016
______________________________________________________________________________

<html>
<head><title>TODAYS DATE</title>
</head>
</html>
<?php
echo "Today is ".date("d/m/Y");
echo "<br/>Today is ".date("D-M-Y");
echo "<br/>Today is ".date("l d")." <sup>th</sup> of ".date("F Y");
?>

PROGRAM NO: 3
AIM : SORTING IN ASSOCIATIVE ARRAY
DATE : 22/02/2016
______________________________________________________________________________
<html>
<head>
<title></title>
</head>
<body>
<form id="myform" name="myform" action="" method="POST">
<table>
<tr>
<td>Enter the number of elements in the array</td>
<td><input type="text" name="no" value="<?php echo $_POST['no']; ?>"/></td>
<td><input type="submit" value="submit" name="sub1"/></td>
</tr>
</table>
<?php
$num=0;
if(isset($_POST['sub1']))
{
echo'Enter the elements';
$num=$_POST['no'];
echo'<table><tr><th>Key</th><th>Value</th></tr>';
for($i=0;$i<$num;$i++)
echo"<tr><td><input type='text' name='key$i'/></td>";
echo"<td><input type='text' name='val$i'/></td></tr>";
}
echo'</table><input type="submit" value="submit" name="sub2"/>';
}
if(isset($_POST['sub2']))
{
$num=$_POST['no'];
//echo "worked".$num;
for($j=0;$j<$num;$j++)
{
$key=$_POST["key$j"];
$val=$_POST["val$j"];
$arr[$key]=$val;
//echo "$val";
}
echo 'ASCENDING ORDER <br/>';
asort($arr);
foreach($arr as $k=> $v)
{
echo "$k = $v <br/>";

}
echo 'DESCENDING ORDER <br/>';
arsort($arr);
foreach($arr as $k=> $v)
{
echo "$k = $v <br/>";
}
}
?>
</body>

</html>

PROGRAM NO: 4
AIM : CREATION AND DSPLAY OF TEXT FILE
DATE : 22/02/2016
______________________________________________________________________________
<html>
<head>
<title>Prg4 TextFile</title>
</head>
<body>
<form name="myform" method="get">
<textarea name="text"></textarea><br/>
<input type="submit" name="write" value="Write to File"/><br/>
<input type="submit" name="show" value="Read from file"/></br>
</form>
</body>
<?php
if(isset($_GET['write'])){
$text=$_GET['text'];
$file = fopen("test.txt","w") or die("Unable to write! Access Denied");
if(fwrite($file,$text)>0){
echo "File write success";
}
fclose($file);
}
if(isset($_GET['show'])){
$myfile = fopen("test.txt", "r") or die("Unable to open file!");
echo fread($myfile,filesize("test.txt"));
fclose($myfile);
}
?>
</html>

PROGRAM NO: 5
AIM : CREATION OF COOKIE TO STORE USERNAME & PASSWORD
DATE : 01/03/2016
_________________________________________________________________________
<html>
<head>
<title>Prg6 Cookies</title>
</head>
<body>
<?php
if(isset($_POST['submit'])){
$userName=$_POST['userName'];
$password=$_POST['password'];
setcookie("userName", $userName);
setcookie("password", $password);
echo "Login success";
exit;
}
?>
<form name="myform" method="post">
<table>
<tr>
<td> User Name</td>
<td><input type="text" name="userName" value="<?php echo
$_COOKIE['userName'];?>"/></td>
</tr>
<tr>
<td> Password</td>
<td><input type="password" name="password" value="<?php echo
$_COOKIE['password'];?>"/></td>
</tr>
<tr>
<td><input type="submit" name="submit" value="Login"/></td>
</tr>
</table>
</form>
</body>
</html>

PROGRAM NO: 6
AIM : INTEGER VALIDATION
DATE : 01/03/2016
_________________________________________________________________________
<html>
<head>
<title>
Prg7 Interger
</title>
</head>
<body>
<form name="myform" method="get" >
Enter an Integer
<input type="text" name="num"/><br/>
<input type="submit" name="submit" value="submit"/><br/>
<?php
if(isset($_GET['submit'])){
$var=$_GET['num'];
if(filter_var($var,FILTER_VALIDATE_INT)){
echo"\n $var The value is an integer";
}
else{
echo"\nThe value is not an integer";
}
}
?>
</body>
</html>

PROGRAM NO: 7
AIM : EMAIL ID VALIDATION
DATE : 08/03/2016
_________________________________________________________________________
<html>
<head>
<title>EMAIL</title>
</head>
<body>
<form name="myform" method="POST" >
<table>
<tr>
<td>Enter an EMAIL</td>
<td><input type="text" name="email"></td>
</tr>
<tr>
<td><input type="submit" name="submit" value="submit"></td>
</tr>
</table>
<?php
if(isset($_POST['submit'])){
$var=$_POST['email'];
if(filter_var($var,FILTER_VALIDATE_EMAIL)){
echo" $var is valid email";
}
else{
echo"invalid email";
}
}
?>
</body>
</html>

PROGRAM NO: 8
AIM : OPERATIONS ON STRINGS
DATE : 08/04/2016
_________________________________________________________________________
<html>
<head>
<title>EMAIL</title>
</head>
<body>
<form name="myform" method="get" >
<table>
<tr>
<td>Enter a String</td>
<td><input type="text" name="string"></td>
</tr>
<tr>
<td><input type="submit" name="submit" value="submit"></td>
</tr>
</table>
</form>
<?php
if(isset($_GET['submit'])){
$var=$_GET['string'];
echo '<table><tr><td>Length<td><td>'.strlen($var).'<td></tr>';
echo '<tr><td>Reverse<td><td>'.strrev($var).'<td></tr>';
echo '<tr><td>Uppercase<td><td>'.strtoupper($var).'<td></tr>';
echo '<tr><td>Lowercase<td><td>'.strtolower($var).'<td></tr></table>';
}
?>
</body>
</html>

PROGRAM NO: 9
AIM : IMPLEMENTATION CONSTRUCTOR & DESTRUCTOR
DATE : 31/04/2016
_________________________________________________________________________
<html>
<head>
<title>Const or Dest</title>
</head>
<body>
<form action="" method="get">
<input type="Submit" name="Submit"/>
</form>
<?php
class some {
public function __construct() {
echo "Constructor called";
}
public function __destruct() {
echo "<br/>Destructor called";
}
}
if(isset($_GET['Submit'])){
$somes = new some();
}
?>
</body>
</html>

PROGRAM NO: 10
AIM : IMPLEMENTATION OF INHERITANCE
DATE : 04/05/2016
_________________________________________________________________________
<html>
<head>
<title>Inhertance</title>
</head>
<body>
<form action="" method="get">
<input type="Submit" name="Submit"/>
</form>
<?php
class Bird {
public function fly() {
echo "Fly method of Bird Class called<br/>";
}
}
class Eagle extends Bird {
public function longDistance() {
echo "longDistance method of the Eagle Class called<br/>";
}
}
if(isset($_GET['Submit'])){
$e = new Eagle();
$e->fly();
$e->longDistance();
}
?>
</body>
</html>

PROGRAM NO: 11
AIM : UPDATION OF STUDENT DATABASE USING MYSQL
DATE : 05/05/2016
_________________________________________________________________________

<html>
<head>
<title>Student Details</title>
</head>
<body>
<form action="" method="POST">
<table>
<tr>
<th colspan="2">Add New</th>
</tr>
<tr>
<td>Name</td><td><input type="text" name="name"/></td>
</tr>
<tr>
<td>Roll.No.</td><td><input type="text" name="rollNo"/></td>
</tr>
<tr>
<td>Year</td><td><input type="text" name="year"/></td>
</tr>
<tr>
<td>Total Mark(%)</td><td><input type="text"
name="markAvg"/></td>
</tr>

</table>

<input type="Submit" value="Add" name="Submit"/>


</form>
<table>
<tr><th colspan="4">Student Record List</th></tr>
<tr>
<th>Name</th><th> Roll No.</th><th>Year</th><th>Mark(%)</th>
</tr>
<?php

$servername = "localhost";
$username = "root";
$password = "kvmceit";
$dbname = "children";
$conn = mysqli_connect($servername, $username, $password, $dbname);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql1 = "SELECT * FROM children";
$result = mysqli_query($conn, $sql1);
if (mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_assoc($result)) {
echo
'<tr><td>'.$row["name"].'</td><td>'.$row["rollno"].'</td><td>'.$row["year"].'</td><td>'.$row["markavg"
].'<td</tr>';
}
}

if(isset($_POST['Submit'])){
$sql = 'INSERT INTO children
VALUES("'.$_POST['name'].'",'.$_POST['rollNo'].','.$_POST['year'].','.$_POST['markAvg'].')';
if (mysqli_query($conn, $sql)) {
header("location:12StudentDetails.php");
} else {

echo "Error: " . $sql . "<br>" . mysqli_error($conn);


}
}
mysqli_close($conn);
?>
</table>
</body>
</html>

PROGRAM NO: 12
AIM : UPDATION OF STUDENT DATABASE USING MYSQL
DATE : 07/05/2016
_________________________________________________________________________

<html>
<head>
<title>Student Details</title>
</head>
<body>
<table>
<tr><th colspan="5">Student Record List</th></tr>
<tr>
<th>Name</th><th> Roll No.</th><th>Year</th><th>Mark(%)</th><th>Option</th>
</tr>
<?php
$servername = "localhost";
$username = "root";
$password = "kvmceit";
$dbname = "children";
$conn = mysqli_connect($servername, $username, $password, $dbname);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql1 = "SELECT * FROM children";
$result = mysqli_query($conn, $sql1);
if (mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_assoc($result)) {
echo
'<tr><td>'.$row["name"].'</td><td>'.$row["rollno"].'</td><td>'.$row["year"].'</td><td>'.$row["m
arkavg"].'<td><td><a
href="13EditStudentDetails.php?RollNo='.$row["rollno"].'">Edit</a></td></tr>';

}
}
if(isset($_POST['Submit'])){
$sql = 'UPDATE children SET name="'.$_POST['name'].'", year='.$_POST['year'].',
markavg='.$_POST['markAvg'].' WHERE rollno='.$_POST['rollNo'];
if (mysqli_query($conn, $sql)) {
header("location:13EditStudentDetails.php");
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
}
if(isset($_GET['RollNo'])){
$sql2 = "SELECT * FROM children WHERE rollno=".$_GET['RollNo'];
$result1 = mysqli_query($conn, $sql2);
while($row1 = mysqli_fetch_assoc($result1)) {
$name=$row1["name"];
$rollNo=$row1["rollno"];
$year=$row1["year"];
$markAvg=$row1["markavg"];
}
}
mysqli_close($conn);
?>
</table>
<form action="" method="POST">
<table>
<tr>
<th colspan="2">Add New</th>
</tr>
<tr>
<td>Name</td><td><input type="text" name="name"
value="<?php echo $name;?>"/></td>

</tr>
<tr>
<td>Roll.No.</td><td><input type="text" name="rollNo"
readonly="true" value="<?php echo $rollNo;?>"/></td>
</tr>
<tr>
<td>Year</td><td><input type="text" name="year" value="<?php echo $year;?>"/></td>
</tr>
<tr>
<td>Total Mark(%)</td><td><input type="text" name="markAvg" value="<?php echo
$markAvg;?>"/></td>
</tr>
</table>
<input type="Submit" value="Update" name="Submit"/>
</form>
</body>
</html>

PROGRAM NO: 13
AIM : DELETION OF STUDENT DETAILS USING MY SQL
DATE : 18/05/2016
_________________________________________________________________________
<html>
<head>
<title>Student Details</title>
</head>
<body>
<table>
<tr><th colspan="5">Student Record List</th></tr>
<tr>
<th>Name</th><th> Roll No.</th><th>Year</th>
<th>Mark(%)</th><th>Option</th>
</tr>
<?php
$servername = "localhost";
$username = "root";
$password = "kvmceit";
$dbname = "children";
$conn = mysqli_connect($servername, $username, $password, $dbname);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql1 = "SELECT * FROM children";
$result = mysqli_query($conn, $sql1);
if (mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_assoc($result)) {
echo
'<tr><td>'.$row["name"].'</td><td>'.$row["rollno"].'</td><td>'.$row["year"].'</td><td>'.$row["m
arkavg"].'<td><td><a
href="14DeleteSudentDetails.php?RollNo='.$row["rollno"].'">Delete</a></td></tr>';

}
}
if(isset($_GET['RollNo'])){
$sql2 = "DELETE FROM children WHERE ROLLNO=".$_GET['RollNo'];
$result1 = mysqli_query($conn, $sql2);
header("location:14DeleteSudentDetails.php");
}
mysqli_close($conn);
?>
</table>
</body>
</html>

Das könnte Ihnen auch gefallen