You are on page 1of 31

Institute of Technology & Management

Bhilwara (Raj.) - 311001

Name: ………………………………………… Roll No: ……………………………

Semester: …………………………………….. Branch: Information Technology

Name of Lab: …………………………………………………………………………..

Index
S.No. Assignment Date Grade Signature

1. Create web pages to understand the / /2011


various server controls & to learn Data
Binding?

2. Create web pages to understand and use / /2011


to validate user inputs.

3. Create web pages to learn how to / /2011


navigate between web pages and
servers.

4. Create login form and validate it / /2011


username/ password stored in database
through PHP?

5. Create student record and perform / /2011


following operations: Add record,
delete, and edit, search record,
navigation between records?

6. A web application display product names / /2011


and price in tabular formats. Each row
containing product detail should display
Know More button. When the button is
clicked the description for the selected item
should be displayed?
Q.1). Create web pages to understand the various server controls?

Code:-

server.php:-
<html>

<head>

<title>Untitled Document</title>

</head>

<body>

Name <input type="text" name="textfield" />

Roll Number <input type="text" name="textfield2" />

Class

<select name="select">

<option>First Year</option>

<option>Second Year</option>

<option>Third Year</option>

<option>Fourth Year</option>

</select>

Hobbies

<input type="checkbox" name="checkbox" value="Playing" />Playing

<input type="checkbox" name="checkbox2" value="checkbox" />Singing

<input type="checkbox" name="checkbox3" value="checkbox" />Dancing

Percentage <input type="text" name="textfield3" />


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

</body>

</html>
Output:-
Q.2). Create web pages to understand and use to validate user inputs?

Code:-
Validate.php:-

<html>

<head>

<title>Untitled Document</title>

<script language="javascript" type="text/javascript">

function checkform(form)

if (form.name.value == "")

alert("Please enter something in name field....");

form.name.focus();

return false;

else

return true;

if (form.fname.value == "")

alert("Please enter something in Fathers name field....");


form.name.focus();

return false;

else

return true;

if (form.phn.value == "")

alert("Please enter something in Phone field....");

form.name.focus();

return false;

else if(ereg("^[0-9]{6}$"))

$errmsg = 'Please enter your valid phone number';

else

return true;

var regex = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;


if(form.email.value.length<1)

alert("You cannot leave the email field empty");

return false;

return true;

</script>

</head>

<body>

<form method="post" onsubmit="return checkform(this)">

<p>Name <input type="text" name="name">

</p>

<p>Fathers Name <input type="text" name="fname" />

</p>

<p>Phone Number <input type="text" name="phn" />

</p>

<p>Email

<input type="text" name="email" />

</p>

<p>&nbsp;</p>

<p>
<input type="submit" name="Submit" value="Submit" />

</p>

</body>

</html>
Output:-

Validate.php:-
Q.3). Create web pages to learn how to navigate between web pages and servers?

Code:-
navigate.php:-

<html>

<head>

<title>Untitled Document</title>

</head>

<body>

<form method="post" action="next.php">

<table width="857" height="412" border="1">

<tr>

<td width="261"><div align="center">Name</div></td>

<td width="580">

<input name="name" type="text" id="name" /></td>

</tr>

<tr>

<td>Roll Number </td>

<td><input name="rollno" type="text" id="rollno" /></td>

</tr>

<tr>

<td><div align="center">Marks</div></td>

<td><input name="marks" type="text" id="marks" /></td>


</tr>

<tr>

<td><div align="center">Percentage</div></td>

<td><input name="percent" type="text" id="percent" /></td>

</tr>

<tr>

<td><div align="center">Grade</div></td>

<td><input name="grade" type="text" id="grade" /></td>

</tr>

<tr>

<td colspan="2"><label>

<input type="submit" name="Submit" value="Submit" /></td>

</tr>

</table>

</form>

</body>

</html>

next.php:-

<?php

$a = $_POST['name'];

$b = $_POST['rollno'];

$c = $_POST['marks'];
$d = $_POST['percent'];

$e = $_POST['grade'];

?>

<html>

<head>

<title>Untitiled</title>

</head>

<body>

Your name is <?php echo $a;?>

<br>

<br>

Your Roll Number is <?php echo $b;?>

<br>

<br>

You got <?php echo $c;?> marks

<br>

<br>

Your percentage is <?php echo $d;?>

<br>

<br>

Your grade is <?php echo $e; ?>

</body> </html>
Output:-

Navigate.php

Next.php
Q.4) Create login form and validate it username/password stored in database through
PHP?
Code:-

Login.php

<html>

<head>

<title>Untitled Document</title>

</head>

<body>

<form method="post" action="loginnext.php">

<table width="905" height="208" border="1">

<tr>

<td colspan="2"><h1 align="center"><strong>Login</strong></h1></td>

</tr>

<tr>

<td colspan="2">

<font color="#FF0000">

<?php

$a=$_GET['msg'];

if($a=='notexist')

echo "wrong user name or password";

?>

</font>
</td>

</tr>

<tr>

<td width="492"><div align="right">

<h2><strong>Enter email </strong></h2>

</div>

</td>

<td width="397">

<input type="text" name="email" value="" /> </td>

</tr>

<tr>

<td><div align="right">password</div></td>

<td><input type="password" name="password" value="" /></td>

</tr>

<tr>

<td>&nbsp;</td>

<td><input type="submit" name="Submit" value="Submit" /></td>

</tr>

</table>

</form>

</body>

</html>
Loginnext.php

<?php

include("db.php");

$a=$_POST['email'];

$b=$_POST['password'];

$sql1="SELECT * FROM student WHERE email='$a' and password='$b'";

$sql2=mysql_query($sql1);

$no=mysql_num_rows($sql2);

if($no=='0')

header('Location:login.php?msg=notexist');

else

header('Location:welcome.php');

?>

db.php

<?php

$hostname = "localhost";

$username = "root";

$password = "";

$database = "stu";

mysql_connect($hostname,$username,$password);

mysql_select_db($database);

?>
Output:-

Login.php

Welcome.php
Q.5). Create student record and perform following operations: Add record, delete, and
edit, search record, navigation between records?
Code:-
Index.php:-

<html>

<head>

<title>Untitled Document</title>

</head>

<body>

<a href ="add.php">

<input type="submit" name="Submit" value="Add New Record" />

</a>

<a href="delete.php">

<input type="submit" name="Submit2" value="Delete a Record" />

</a>

<a href="modify.php">

<input type="submit" name="Submit3" value="Search a Record" />

</a>

</body>

</html>
add.php:-

<form method="post" action="addnext.php">

<table width="865" height="372" border="1">

<tr>

<td colspan="2"><h2 align="center" class="style1">Add New Record </h2></td>

</tr>

<tr>

<td width="283">Name</td>

<td width="566"><label>

<input name="name" type="text" id="name" />

</label></td>

</tr>

<tr>

<td>Roll Number </td>

<td><input name="rollno" type="text" id="rollno" /></td>

</tr>

<tr>

<td>Fathers Name </td>

<td><input name="fname" type="text" id="fname" /></td>

</tr>

<tr>

<td>Mothers Name </td>


<td><input name="mname" type="text" id="mname" /></td>

</tr>

<tr>

<td>Date of Birth </td>

<td><input name="dob" type="text" id="dob" /></td>

</tr>

<tr>

<td colspan="2"><label>

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

</label></td>

</tr>

</table>

</form>

addnext.php:-

<?php

include ("db.php");

$a = $_POST['name'];

$b = $_POST['rollno'];

$c = $_POST['fname'];

$d = $_POST['mname'];

$e = $_POST['dob'];
$f = "INSERT INTO CLASS VALUES('$a','$b','$c','$d','$e')";

mysql_query($f);

header("location:add.php");

?>

delete.php:-

<form method="post" action="deletenext.php">

<table width="913" height="215" border="1">

<tr>

<td colspan="2" class="style1">Delete The Record </td>

</tr>

<tr>

<td width="289">Enter Roll Number </td>

<td width="608">

<input name="rollno" type="text" id="rollno" /></td>

</tr>

<tr>

<td colspan="2"><label>

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

</label></td>

</tr>

</table>

</form>
deletenext.php:-

<?php

include ("db.php");

$a = $_POST['rollno'];

$b = "DELETE FROM class WHERE rollno = '$a'";

mysql_query($b);

?>

modify.php:-

<form method="post" action="modifynext.php">

<table width="913" height="215" border="1">

<tr>

<td colspan="2" class="style1”>Modify the record td>

</tr>

<tr>

<td width="289">Enter Roll Number </td>

<td width="608"><label>

<input name="rollno" type="text" id="rollno" /></td>

</tr>

<tr>

<td colspan="2"><label>

<input type="submit" name="Submit" value="Submit" /></td>

</tr>
</table>

</form>

modifynext.php:-

<?php

include ("db.php");

$a = $_POST['rollno'];

$b = "Select * from clas where rollno ='$a'";

$c = mysql_query($b);

?>

<body>

<table width="893" height="330" border="1">

<tr>

<td width="215">Name</td>

<td width="662"><?php echo $c[0];?></td>

</tr>

<tr>

<td>Roll Number </td>

<td><?php echo $c[1];?></td>

</tr>

<tr>

<td>Fathers Name </td>


<td><?php echo $c[2];?></td>

</tr>

<tr>

<td>Mothers Name </td>

<td><?php echo $c[3];?></td>

</tr>

<tr>

<td>Date of Birth </td>

<td><?php echo $c[4];?></td>

</tr>

</table>
Output:-

Index.php

Add.php
Delete.php

Modify.php
Q.6). A web application display product names and price in tabular formats. Each
row containing product detail should display Know More button. When the button is
clicked the description for the selected item should be displayed?
Code:-
index.php:-

<html>

<head>

<title>Untitled Document</title>

</head>

<body>

<table width="949" height="421" border="1">

<tr>

<td width="70"><div align="center" class="style2">

<h3>S.No.</h3></td>

<td width="272"><div align="center" class="style2">

<h3>Product Name </h3></div></td>

<td width="187"><div align="center" class="style2">

<h3>Product Price </h3></div></td>

<td width="392"><div align="center" class="style2">

<h3>Product Detail </h3></div></td>

</tr>

<tr>

<td>1</td>
<td>Nokia E7 Mobile Phone</td>

<td>Rs. 28295 </td>

<td><div align="right">Latest Nokia cell phone with a very light weight and some new
existing features....

<a href="nokiae7.php"> Know More</a> </div></td>

</tr>

<tr>

<td>2</td>

<td>Panasonic Cordless Phone</td>

<td>Rs.4500</td>

<td><div align="right">Panasonic cordless phone with a very high frequency range and
also phonebook facility....

<a href="panasonic.php"> Know More</a> </div></td>

</tr>

<tr>

<td>3</td>

<td>Nokia 1616 </td>

<td>Rs.1266</td>

<td><div align="right">Nokia 1616, cheapest phone in its range, very good for people who
just want to receive are call people....

<a href="nokia1616.php">Know More</a></div></td>

</tr>

<tr>
<td>4</td>

<td>Sony Ericsson Express </td>

<td>Rs.31499</td>

<td><div align="right">Sony ericson Express,a latest Sony mobile handset which gives you
a very good gaming experience and also have 3G facility....

<a href="sonyericson.php">Know More</a></div></td>

</tr>

<tr>

<td>5</td>

<td>Sony Cybershot DSC </td>

<td>Rs.4675</td>

<td><div align="right">Latest Sony camera which gives you a very high quality image with
its camera of 10.1 megapixels....

<a href="sonycyber.php">Know More</a></div></td>

</tr>

<tr>

<td>6</td>

<td>Mosar bear MP3 Player</td>

<td>Rs.1299</td>

<td><div align="right">Mosar Bear MP3 player gives you facility to play both mp3and
wma digital music files....

<a href="moserbear.php">Know More</a></div></td>

</tr>
<tr>

<td>7</td>

<td>Nikon Digital Camera </td>

<td>Rs.6375</td>

<td><div align="right">Nikon Coolpix Camera can store image in five different formats....

<a href="nikoncool.php">Know More</a></div></td>

</tr>

</table>

</body>

</html>
Output:-

Index.php

You might also like