<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Filter Concepts</title> </head> <body> <form name="form" method="post" action="" onsubmit="return validation();"> <h1 align="center" style="color:#03C;">Student Records</h1> <div id="container"> <p><strong>Name </strong><input type="text" name="name" value="" /><em id="name"></em></p> <p><strong>Roll No </strong><input type="text" name="rollno" value="" /><em id="rollno" > </em></p> <p><strong>D.O.B </strong><input type="text" name="dob" value="" /><em id="dob"> </em></p> <p><strong>Tamil </strong><input type="text" name="tamil" value=""/><em id="tamil"></em></p> <p><strong>English </strong><input type="text" name="english" value="" /><em id="english" > </em></p> <p><strong>Maths </strong><input type="text" name="maths" value="" /><em id="maths"></em></p> <p><strong>Science </strong><input type="text" name="science" value="" /><em id="science"></em></p> <p><strong>Social Science </strong><input type="text" name="social" value="" /><em id="social"></em></p> <p><strong>Total Marks </strong><input type="text" name="total" value="" /><em id="total" ></em></p> <p style="margin-left:300px;"><input type="submit" name="submit" value="submit" /> <a href="view.php"><input type="button" name="view" value="view" /> </a> <a href="search.php"><input type="button" name="search" value="search" /></a> </p> </div> </body> </html>
style:
<style type="text/css"> Body{background:#CC9; } #container{margin:0 auto; background:#CC9; border:10px solid gray; width:50%; height:500PX; border-radius:20px;} p { color:#000; margin:3% auto; margin-left:200px; } </style>
JS:
<script type="text/javascript"> function validation() { var name=document.form.name.value; if(name=="" || name=="null") { document.getElementById('name').innerHTML="Enter Ur Name"; document.getElementById('rollno').innerHTML=""; document.form.name.focus(); return false; } var rollno=document.form.rollno.value; if(rollno=="" || rollno=="null") { document.getElementById('name').innerHTML=""; document.getElementById('rollno').innerHTML="Enter Ur Rollno"; document.getElementById('dob').innerHTML=""; document.form.rollno.focus(); return false; } var dob=document.form.dob.value; if(dob=="" || dob=="null") { document.getElementById('name').innerHTML=""; document.getElementById('rollno').innerHTML=""; document.getElementById('dob').innerHTML="Enter ur DOB"; document.form.dob.focus(); return false; } var tamil=document.form.tamil.value; if(tamil=="" || tamil=="null") { document.getElementById('name').innerHTML=""; document.getElementById('rollno').innerHTML=""; document.getElementById('dob').innerHTML=""; document.getElementById('tamil').innerHTML="Enter ur Tamil Mark"; document.form.tamil.focus(); return false; } var english=document.form.english.value; if(english=="" || english=="null") { document.getElementById('name').innerHTML=""; document.getElementById('rollno').innerHTML=""; document.getElementById('dob').innerHTML=""; document.getElementById('tamil').innerHTML=""; document.getElementById('english').innerHTML="Enter Ur mark"; document.form.english.focus(); return false; } var maths=document.form.maths.value; if(maths=="" || maths=="null") { document.getElementById('name').innerHTML=""; document.getElementById('rollno').innerHTML=""; document.getElementById('dob').innerHTML=""; document.getElementById('tamil').innerHTML=""; document.getElementById('english').innerHTML=""; document.getElementById('maths').innerHTML="Enter Ur mark"; document.form.maths.focus(); return false; } var science=document.form.science.value; if(science=="" || science=="null") { document.getElementById('name').innerHTML=""; document.getElementById('rollno').innerHTML=""; document.getElementById('dob').innerHTML=""; document.getElementById('tamil').innerHTML=""; document.getElementById('english').innerHTML=""; document.getElementById('maths').innerHTML=""; document.getElementById('science').innerHTML="Enter Ur mark"; document.form.science.focus(); return false; } var social=document.form.social.value; if(social=="" || social=="null") { document.getElementById('name').innerHTML=""; document.getElementById('rollno').innerHTML=""; document.getElementById('dob').innerHTML=""; document.getElementById('tamil').innerHTML=""; document.getElementById('english').innerHTML=""; document.getElementById('maths').innerHTML=""; document.getElementById('science').innerHTML=""; document.getElementById('social').innerHTML="Enter Ur mark"; document.form.social.focus(); return false; } var total=document.form.total.value; if(total=="" || total=="null") { document.getElementById('name').innerHTML=""; document.getElementById('rollno').innerHTML=""; document.getElementById('dob').innerHTML=""; document.getElementById('tamil').innerHTML=""; document.getElementById('english').innerHTML=""; document.getElementById('maths').innerHTML=""; document.getElementById('science').innerHTML=""; document.getElementById('social').innerHTML=""; document.getElementById('total').innerHTML="Enter Ur mark"; document.form.total.focus(); return false; } } </script>
php:
<?php
$cnt=mysql_connect("localhost","root","");
$select_db=mysql_select_db("filter",$cnt);
if(isset($_POST['submit']))
{
$name=$_POST['name'];
$rollno=$_POST['rollno'];
$dob=$_POST['dob'];
$tamil=$_POST['tamil'];
$english=$_POST['english'];
$maths=$_POST['maths'];
$science=$_POST['science'];
$social=$_POST['social'];
$total=$_POST['total'];
print_r($_POST);
$insert=mysql_query("insert into filter_tbl(name,rollno,dob,tamil,english
maths,science,social,total) values('$name','$rollno','$dob','$tamil',
'$english','$maths','$science','$social','$total')",$cnt);
if($insert)
{
header("location:index.php");
}
}
?>
search.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Search</title> <style> #container{margin:0 auto; background:#999; border:10px solid gray; width:50%; height:auto; margin:5% auto; border-radius:20px;} p { margin:3% auto; margin-left:100px; border:0px solid red; } #header { margin:6% auto; margin-left:10px; } </style> </head> <body> <form name="form" method="post" action=""> <h1 align="center" style="color:#03C;">Student Records</h1> <div id="container"> <div id="header"> <p> Enter Name <input type="text" name="name" value="" /> Roll NO <input type="text" name="rollno" value="" /> <em><input type="submit" name="submit" value="submit" /></em></p> </div> <?php $cnt=mysql_connect("localhost","root",""); $select_db=mysql_select_db("filter",$cnt); $error="not found"; if(isset($_POST['submit'])) { $name1=$_POST['name']; $rollno=$_POST['rollno']; $r=mysql_query("select * from filter_tbl where name='$name1' and rollno='$rollno' "); if($name1!="" || $rollno!=="") { while($row=mysql_fetch_array($r)) { $name=$row['name']; $rollno=$row['rollno']; $dob=$row['dob']; $tamil=$row['tamil']; $english=$row['english']; $maths=$row['maths']; $science=$row['science']; $social=$row['social']; $total=$row['total']; ?> <p> <strong style="color:#000;"> <?php echo $row['id']; ?> </strong> <strong style="color:#000;"> <?php echo $name; ?> </strong> <strong style="color:#000;"> <?php echo $rollno; ?> </strong> <strong style="color:#000;"> <?php echo $tamil; ?> </strong> <strong style="color:#000;"> <?php echo $english; ?> </strong> <strong style="color:#000;"> <?php echo $maths; ?> </strong> <strong style="color:#000;"> <?php echo $science; ?> </strong> <strong style="color:#000;"> <?php echo $social ?> </strong> <strong style="color:#000;"> <?php echo $total; ?> </strong> </p> <?php } ?> <?php } else { echo "<script>alert('not found')</script>"; } } ?> </div> </form> </body> </html>
view.php
<?php $cnt=mysql_connect("localhost","root",""); $select_db=mysql_select_db("filter",$cnt); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>View</title> <style> #container{margin:0 auto; background:#999; border:10px solid gray; width:60%; margin:5% auto; height:auto; border-radius:20px;} p { margin-left:50px; color:#03C; } </style> </head> <body> <div id="container"> <p><h1 align="center" style="color:#03C;">Student Records</h1></p> <p> <strong style="color:#000;">S.No</strong> <strong style="color:#000;">Name</strong> <strong style="color:#000;">Rollno</strong> <strong style="color:#000;">D.O.B</strong> <strong style="color:#000;">Tamil</strong> <strong style="color:#000;">English</strong> <strong style="color:#000;">Maths</strong> <strong style="color:#000;">Science</strong> <strong style="color:#000;"> Social Science</strong> <strong style="color:#000;">Total</strong><p><hr /></p> </p> <?php $cnt=mysql_connect("localhost","root",""); $select_db=mysql_select_db("filter",$cnt); $select_tbl=mysql_query("select * from filter_tbl"); $x=1; while($row=mysql_fetch_array($select_tbl)) { $name=$row['name']; $rollno=$row['rollno']; $dob=$row['dob']; $tamil=$row['tamil']; $english=$row['english']; $maths=$row['maths']; $science=$row['science']; $social=$row['social']; $total=$row['total']; ?> <p><strong style="color:#000;"><?php echo $x++; ?></strong> <strong style="color:#000;"><?php echo $name; ?></strong> <strong style="color:#000;"><?php echo $rollno; ?></strong> <strong style="color:#000;"><?php echo $tamil; ?></strong> <strong style="color:#000;"><?php echo $english; ?></strong> <strong style="color:#000;"><?php echo $maths; ?></strong> <strong style="color:#000;"><?php echo $science; ?></strong> <strong style="color:#000;"> <?php echo $social ?></strong> <strong style="color:#000;"><?php echo $total; ?></strong> <hr /> </p> <?php } ?> </div> </body> </html>
No comments:
Post a Comment