OneCompiler

WT Lab 2

222

6th

<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/css" href="student.css"?> <students> <student> <sname>Ankush</sname> <usn>4SF15CS001</usn> <college>SCEM</college> <branch>CSE</branch> <yoj>2015</yoj> <email>[email protected]</email> </student> <student> <sname>Rayan</sname> <usn>4SF15CS003</usn> <college>SCEM</college> <branch>CSE</branch> <yoj>2015</yoj> <email>[email protected]</email> </student> <student> <sname>Pavan</sname> <usn>4SF15CS006</usn> <college>SCEM</college> <branch>CSE</branch> <yoj>2015</yoj> <email>[email protected]</email> </student> </students>

7th

<html> <head> <title>Visitors Count</title> <style type="text/css"> h1,h2 {text-align: center} </style> </head> <body> <h1>Welcome to MY WEB PAGE</h1> <?php $file="count.txt"; $handle=fopen($file,'r') or die("Cannot Open File : $file"); $count=fread($handle,10); fclose($handle); $count++; echo "<h2>No of visitors who visited this page : $count </h2>"; $handle=fopen($file,'w') or die("Cannot Open File : $file"); fwrite($handle,$count); fclose($handle); ?> </body> </html>

8th

<html> <head> <meta http-equiv="refresh" content="1"> <title>Digital Clock</title> <style type="text/css"> h1 {text-align: center} </style> </head> <body> <?php echo "<h1>Digital Clock</h1>"; echo "<hr/>"; echo "<h1>".date('h:i:s A')."</h1>"; echo "<hr/>"; ?> </body> </html>

9th

9a.html

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Simple Calculator</title> </head> <body> <form action="8a.php" method="post"> <h1>Simple Calculator</h1> <p>First Operand: <input type="text" name="op1" /></p> <p>Choose Operator: <input type="radio" name="operator" checked="checked" value="+" /> Add(+) <input type="radio" name="operator" value="-" /> Subtract(-) <input type="radio" name="operator" value="*" /> Multiply(*) <input type="radio" name="operator" value="/" /> Divide(/) </p> <p>Second Operand: <input type="text" name="op2"></p> <p> <input type="submit" name="submit" value="Submit"> <input type="reset" name="reset" value="Reset"> </p> </form> </body> </html>

9a.php

<html> <head> <title>Result Page</title> <style type="text/css"> h1,h2 {text-align: center} </style> </head>
<body>
	<?php
	$op1=$_POST['op1'];
	$op2=$_POST['op2'];
	$operator=$_POST['operator'];
	switch($operator)
	{
		case '+':$res=$op1+$op2;
			 break;
		case '-':$res=$op1-$op2;
			 break;
		case '*':$res=$op1*$op2;
			 break;
		case '/':if($op2==0)
			 {
				echo "divide by zero error";
				exit;
			 }
			 else
			 	$res=$op1/$op2;
			 break;

	}
	echo "<h1>Simple Calculator</h1>";
	echo "<h2>".$op1.$operator.$op2."=".$res."</h2>"; ?>
</body>
</html>