A college has given roll number to each student, The roll number is six digit number where first two digits are faculty(B.Sc., BCA, BA) third digit is year (Ist(1), IInd(2) and IIIrd(3)) and last three digit are actual number. Write PHP script to accept a number and print faculty, year and roll number of student.(e.gRollno=BC1004,faculty=BCA, year=1st,rollno=004)
Student.html
<html>
<body>
<form method=get action="student.php">
Enter <input type=text name="a"><br>
<input type=submit value=submit>
</form>
</body>
</html>
//Student.php
<?php
$a=$_GET['a'];
if(ereg("^BC|A|S([1-3])([0-9][0-9][0-9])$",$a))
{
echo"Roll no = ".substr($a,3)."<br>";
$year=substr($a,2,1);
if($year=='1')
echo"Year = 1st <br>";
if($year=='2')
echo"Year = 2nd <br>";
if($year=='3')
echo"Year = 3rd <br>";
$fac=substr($a,0,2);
if($fac=='BA')
echo"Faculty = BA";
if($fac=='BC')
echo"Faculty = BCA";
if($fac=='BS')
echo"Faculty = B.Sc.";
}
else
{
echo"Invalid ";
}
?>
<html>
<body>
<form method=get action="student.php">
Enter <input type=text name="a"><br>
<input type=submit value=submit>
</form>
</body>
</html>
//Student.php
<?php
$a=$_GET['a'];
if(ereg("^BC|A|S([1-3])([0-9][0-9][0-9])$",$a))
{
echo"Roll no = ".substr($a,3)."<br>";
$year=substr($a,2,1);
if($year=='1')
echo"Year = 1st <br>";
if($year=='2')
echo"Year = 2nd <br>";
if($year=='3')
echo"Year = 3rd <br>";
$fac=substr($a,0,2);
if($fac=='BA')
echo"Faculty = BA";
if($fac=='BC')
echo"Faculty = BCA";
if($fac=='BS')
echo"Faculty = B.Sc.";
}
else
{
echo"Invalid ";
}
?>
Comments
Post a Comment