1)Write PHP script to create a CD
catalog using XML file.
catalogue.xml
<?xml version="1.0" ?>
<?xml-stylesheet
type="text/css" href="catlogue.css"?>
<CATALOG>
<CD
code="B1">
<TITLE>Empire
Burlesque</TITLE>
<ARTIST>Bob
Dylan</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Columbia</COMPANY>
<PRICE>10.90</PRICE>
<YEAR>1985</YEAR>
</CD>
<CD code="B2">
<TITLE>Hide
your heart</TITLE>
<ARTIST>Bonnie
Tyler</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>CBS
Records</COMPANY>
<PRICE>9.90</PRICE>
<YEAR>1988</YEAR>
</CD>
</CATALOG>
Catalogue.php
<html>
<head>
<link
rel="stylesheet" type="text/css"
href="catlogue.css">
</head>
<body>
<?php
$xml=simplexml_load_file('catlogue.xml')or
die("cannot die");
?>
<center>
</b>CD details</b></center>
<table
border="1">
<th>CD
code</th>
<th>Title</th>
<th>ARTIST</th>
<th>COUNTRY</th>
<th>COMPANY</th>
<th>PRICE</th>
<th>Year</th>
<?php
foreach($xml->CD
as $a)
{
echo"<tr><td>".$a['code']."</td>";
echo"<td>".$a->TITLE."</td>";
echo"<td>".$a->ARTIST."</td>";
echo"<td>".$a->COUNTRY."</td>";
echo"<td>".$a->COMPANY."</td>";
echo"<td>".$a->PRICE."</td>";
echo"<td>".$a->YEAR."</td>
</tr>";
}
?>
</table>
</body>
</html>
catlogue.css
table th{color:blue; font-size: 20pt;}
table td{color:green; font-size: 20pt;}
2)Write a program to create a
shopping mall. Usermust be allowed to do purchase from three pages. Each page
should have a pagetotal. The fourth page should display a bill, which consists
of a page total ofwhatever the purchase has been done and print the total. (Use
$_SESSION).
first.php
<html>
<head><title>Shopping
Mall</title></head>
<body>
<form
method ="post" action="second.php">
<b>Wow
Shopping</b>
<table>
<tr>
<td>
<table>
<tr>
<td><b>Java
Book</b><input type="radio" name="book"
value="java"></td>
<td><b>Prize:100</b></td>
</tr>
<tr>
<td><b>CPP
Book</b><input type="radio" name="book"
value="cpp"></td>
<td><b>Prize:120</b></td>
</tr>
<tr>
<td><b>IT
Book</b><input type="radio" name="book"
value="it"></td>
<td><b>Prize:150</b></td>
</tr>
</table>
</td>
</tr>
<tr><td><input
type="submit" name="submit"
value="Purchase"></td></tr>
</table>
</form>
</body>
</html>
second.php
<html>
<body>
<?php
session_start();
if(isset($_POST['book']))
{
if($_POST['book'] == 'java')
{
$_SESSION["bprize"]=100;
$_SESSION["bname"]=$_POST["book"];
}
if($_POST['book'] == 'cpp')
{
$_SESSION["bprize"]=120;
$_SESSION["bname"]=$_POST["book"];
}
if($_POST['book'] == 'it')
{
$_SESSION["bprize"]=150;
$_SESSION["bname"]=$_POST["book"];
}
}
?>
<form method ="post" action="third.php">
<b>Wow
Shopping Mobile</b>
<table>
<tr>
<td>
<table>
<tr>
<td><b>Samsung
</b><input type="radio" name="book"
value="samsung"></td>
<td><b>Prize:10000</b></td>
</tr>
<tr>
<td><b>Micromax</b><input
type="radio" name="book"
value="micromax"></td>
<td><b>Prize:12000</b></td>
</tr>
<tr>
<td><b>Apple</b><input
type="radio" name="book"
value="apple"></td>
<td><b>Prize:15000</b></td>
</tr>
</table>
</td>
</tr>
<tr><td><b>Total</b></td><td><?php
echo $_SESSION['bprize'];?></td></tr>
<tr><td><input
type="submit" name="submit" value="Purchase"></td></tr>
</table>
</form>
</body>
</html>
third.php
<html>
<body>
<?php
session_start();
if(isset($_POST['book']))
{
if($_POST['book'] == 'samsung')
{
$_SESSION["mprize"]=10000;
$_SESSION["mname"]=$_POST["book"];
}
if($_POST['book'] == 'micromax')
{
$_SESSION["mprize"]=12000;
$_SESSION["mname"]=$_POST["book"];
}
if($_POST['book'] == 'apple')
{
$_SESSION["mprize"]=15000;
$_SESSION["mname"]=$_POST["book"];
}
}
?>
<form
method ="post" action="fourth.php">
<b>Wow
Shopping Laptop</b>
<table>
<tr>
<td>
<table>
<tr>
<td><b>Samsung
</b><input type="radio" name="book"
value="samsung"></td>
<td><b>Prize:45000</b></td>
</tr>
<tr>
<td><b>Lenovo</b><input
type="radio" name="book"
value="lenovo"></td>
<td><b>Prize:35000</b></td>
</tr>
<tr>
<td><b>Apple</b><input
type="radio" name="book"
value="apple"></td>
<td><b>Prize:60000</b></td>
</tr>
</table>
</td>
</tr>
<tr><td><b>Total</b></td><td><?php
echo $_SESSION['bprize']+$_SESSION['mprize'];?></td></tr>
<tr><td><input
type="submit" value="Purchase"></td></tr>
</table>
</form>
</body>
</html>
fourth.php
<html>
<body>
<?php
session_start();
if(isset($_POST['book']))
{
if($_POST['book'] == 'samsung')
{
$_SESSION["lprize"]=45000;
$_SESSION["lname"]=$_POST["book"];
}
if($_POST['book'] == 'lenovo')
{
$_SESSION["lprize"]=35000;
$_SESSION["lname"]=$_POST["book"];
}
if($_POST['book'] == 'apple')
{
$_SESSION["lprize"]=60000;
$_SESSION["lname"]=$_POST["book"];
}
}
?>
<table>
<tr>
<td>Your
selected Products</td>
</tr>
<tr>
<td>
<?php
echo $_SESSION['bname']; ?>
</td>
<td>
<?php
echo $_SESSION['bprize']; ?>
</td>
</tr>
<tr>
<td>
<?php
echo $_SESSION['mname']; ?>
</td>
<td>
<?php
echo $_SESSION['mprize']; ?>
</td>
</tr>
<tr>
<td>
<?php
echo $_SESSION['lname']; ?>
</td>
<td>
<?php
echo $_SESSION['lprize']; ?>
</td>
</tr>
<tr>
<td><b>Total</b></td>
<td><?php
echo $_SESSION['bprize']+$_SESSION['mprize']+$_SESSION['lprize'];
?></td>
</tr>
</table>
</form>
</body>
</html>