Record Programs With Soln
Record Programs With Soln
{
document.getElementById("n").style.color="orange";
setTimeout(chm6,2000)
}
function chm6()
{
document.getElementById("n").style.color="red";
setTimeout(chm7,2000)
}
function chm7()
{
document.getElementById("n").style.color="aqua";
setTimeout(chm,2000)
}
</script>
</head>
<body onload="chm()">
<marquee id="n"><h1>WEB PROGRAMMING USING PHP</h1>
</marquee></BODY></HTML>
4. Design a student registration page using HTML. Add proper validations
using javascript.
<html> <head> <title>Style demo</title>
<script language="javascript">
function val()
{
var firstname=document.forms["f1"]["fn"].value;
var phone=document.forms["f1"]["ph"].value;
var addr=document.forms["f1"]["add"].value;
if(firstname=="")
{
alert("Name field is empty");
document.forms["f1"]["fn"].value=prompt("Name field is empty");
3
Web Programming using PHP – Record programs
return false;
}
if (isNaN(phone) )
{
alert("phone number is not numeric"); return false;
}
if(addr=="")
{
alert("Address field is empty"); return false;
}
if(confirm("Form is about to save ... Are you sure ?"))
return true;
}
</script> </head>
<body>
<h1>Registration</h1>
<form name="f1" action="" onsubmit="return val()" >
Enter Name <input type="text" name="fn"> <br><br>
Enter Phone number <input type="text" name="ph"> <br><br>
Enter address <textarea name="add"></textarea><br><br>
<input type="submit" name="s" value="save" >
</form> </body></html>
5. Write a php program to find factorial of a number
<?php
$n=8; $f=1;
for($i=1;$i<=$n;$i++)
$f=$f*$i;
4
Web Programming using PHP – Record programs
switch(trim($value))
{
case 'zero':
$result .= '0'; break;
case 'one':
$result .= '1'; break;
case 'two':
$result .= '2'; break;
case 'three':
$result .= '3'; break;
case 'four':
$result .= '4'; break;
case 'five':
$result .= '5'; break;
case 'six':
$result .= '6'; break;
case 'seven':
$result .= '7'; break;
case 'eight':
$result .= '8'; break;
case 'nine':
$result .= '9'; break;
}
} return $result;
}
echo word_digit("zero;three;five;six;eight;one")."<BR>";
echo word_digit("seven;zero;one")."<BR>";
6
Web Programming using PHP – Record programs
$s= word_digit("two;five;seven;zero");
echo $s;
?>
8. Write To Understand how to create session
<?php
session_start();
if( isset( $_SESSION['counter'] ) ) {
$_SESSION['counter'] += 1;
}else {
$_SESSION['counter'] = 1;
}
$msg = "You have visited this page ". $_SESSION['counter'];
$msg .= " in this session.";
?>
<html>
<head>
<title>Setting up a PHP session</title>
</head>
<body>
<?php echo ( $msg ); ?>
</body>
</html>
9. Write a PHP program to count the words in the string which is entered
through a textfield.
<html> <head><title></title></head>
<body>
<form method="get" action="pgm9code.php">
7
Web Programming using PHP – Record programs
mysql_select_db("MYDATA",$con);
$qry="insert into userreg VALUES('$cn','$ad','$phone')";
$i=mysql_query($qry,$con);
if($i>0)
echo "data inserted successfully";
?>
11. Build a web application to accept book information viz. Accession
number, title, authors, edition and publisher from a web page and store the
information in a database and to search for a book with the title specified
by the user and to display the search results with proper headings. Also
perform insert, delete and edit operation. [Hint: use PHP, CSS, and
MySQL. Check all validations and add proper constraints for tables]
12.Employee Details, to perform display, insert, update & delete operations on
employee details using php, CSS,HTML and MySQL database.[Hint:
create tables add proper constraints, check all validations]
13.Create a web application using PHP, CSS & MYSQL program to prepare a
Bill for a super market. Perform insert, delete, edit and search
operations.[Hint: Create minimum two tables, check all validations and add
proper constraints for tables]
14.Write a web program to calculate electricity bill. Perform insert, delete, edit
and search operations.[Hint: use PHP, MySQL, CSS, html create tables add
proper constraints, check all validations, Conditions: For first 50 units – Rs.
3.50/unit. For next 100 units – Rs. 4.00/unit, For next 100 units – Rs.
5.20/unit For units above 250 – Rs. 6.50/unit]
15. Design a web application for Student Information system. create
tables and add proper constrains. Perform insert, delete and search
operation. Also produce the report for a particular item and all items.