1) Change the preferences of your
web page like font style, font size, font color, background color using cookie.
Display selected settings on next web page and actual implementation (with new
settings) on third web page.
font.html
<html>
<body>
<form method="post" action="font.php">
<b>Enter string:</b><input type="text"
name="str" /></br>
<b>Enter font :</b><input type="text"
name="fontname" /></br>
<b>Enter Background color:</b><input type="text"
name="bname" />
<input type="submit" name="submit" />
</form>
</body>
</html>
font.php
<?php
if($_POST['submit']) {
//$fontName = $_POST['fontname'];
//$bcolor = $_POST['bname'];
//$_COOKIE['fname'] =
$_POST['fontname'];
setcookie('bname',$_POST['bname']);
setcookie('fname',$_POST['fontname']);
setcookie('str',$_POST['str']);
echo "<b>Entered String
:</b>".$_POST['str'];
echo "</br><b>Selected
font :</b>".$_POST['fontname'];
echo "</br><b>Selected
Background color :</b>".$_POST['bname'];
echo "</br><a
href='view.php'>View Implmentation</a>";
}
?>
view.php
<html>
<?php
echo "<body bgcolor='".$_COOKIE['bname']."'><font
face='".$_COOKIE['fname']."'
size='8'>".$_COOKIE['str']."</font>";
?>
<html>
2) Write a PHP script to accept an
.XML file which should comprise the following:
<cricket><player>abc</player><runs>1000</runs><wickets>50</wickets><noofnotout>10</noofnotout></cricket>
For at least 5 players.
Display thedetails of players who have scored more than 1000 runs and at least 50 wickets.
<?xml version='1.0'>
<cricketinfo>
<cricket>
<player>abc</player>
<runs>1000</runs>
<wickets>50</wickets>
<noofnotout>10</noofnotout>
</cricket>
<cricket>
<player>aaa</player>
<runs>1000</runs>
<wickets>40</wickets>
<noofnotout>10</noofnotout>
</cricket>
<cricket>
<player>bbb</player>
<runs>1000</runs>
<wickets>40</wickets>
<noofnotout>10</noofnotout>
</cricket>
<cricket>
<player>ccc</player>
<runs>1000</runs>
<wickets>40</wickets>
<noofnotout>10</noofnotout>
</cricket>
<cricket>
<player>ddd</player>
<runs>1000</runs>
<wickets>40</wickets>
<noofnotout>10</noofnotout>
</cricket>
</cricketinfo>
slip28.php
<?php
$d=new DOMDocument();
$d->load("slip28.xml");
$run=$d->getElementsByTagName('runs');
$wic=$d->getElementsByTagName('wickets');
$name=$d->getElementsByTagName('player');
foreach($name as $n)
{
if($run=='1000'
&& $wic>='50')
echo
"<br>".$n->textContent;
else
"not";
}
?>