Search This Blog

Thursday 30 August 2018

2. Write a program to upload and display an image using PHP.
 <HTML>
<HEAD>
<TITLE>PHP PROGRAM TO UPLOAD A FILE.</TITLE>
</HEAD>
<BODY>

<FORM ACTION="fileupload.php" ENCTYPE="MULTIPART/FORM-DATA" METHOD="POST">
<b>Select the Image to upload:</b>
<INPUT TYPE="file" NAME="file"><BR/>
<INPUT TYPE="Submit" VALUE="Upload" NAME="Upload"> <BR/>
</FORM>

<?php
if(isset($_POST['Upload']))
{
    $path = "photos/" . $_FILES["file"]["name"];

    if(move_uploaded_file($_FILES["file"]["tmp_name"], $path))
    {
        echo "<img src=",$path," height=250 width=500 >";
    }
    else
    {
        echo "Error!";
    }
}
?>

</BODY>
</HTML>

1. Write a program to connect the mysql-database and display connection status using PHP.

1. Write a program to connect the mysql-database and display connection status using PHP.
<HTML>
<HEAD>
<TITLE> MYSQL Connection Status</TITLE>
</HEAD>
<BODY BGCOLOR="BEIGE" SIZE=22 TEXT=BLUE>
<?php
$servername = "localhost";
$username = "man";
$password = "";

// Create connection
$conn = new mysqli($servername, $username, $password);

// Check connection
if ($conn->connect_error)
{
    die("Connection failed: " . $conn->connect_error);
}
echo "MySQL Connected successfully.";
?>
</BODY>
</HTML>

Wednesday 15 August 2018

6. Create a webpage to demonstrate the use of external Cascading Style Sheets

6. Create a webpage to demonstrate the use of external Cascading Style Sheets
Code for mystyle.css:
body{
        background-color: orange;
        font-family:serif;
        color: blue;
        font-size: 26pt;
    }

h3{ color:blue; }

.M { color: Magenta; font-style:italic  }
.Y { color:yellow; font-style:bold }
.R { color:Red; text-decoration:underline }

ul {
     list-style-type: square;
   }


Code for External.html:
<HTML>
    <HEAD>
        <TITLE>External CSS</TITLE>
        <LINK  REL="stylesheet" HREF="mystyle.css">
    </HEAD>
    <BODY>
        <H3>Applying Styles using External Cascading Style Sheets</H3>
       
        <span class="M">This text is Italic and Magenta.</span><br>
        <span class="Y">This text is Bold and Yellow.</span><br>
        <span class="R">This text is underlined and Red.</span><br>
       <P>This list is applied with External CSS:</P>
       <ul>
       <li>Element1
       <li>Element2
       </ul>
   
    </BODY>
</HTML>

5. Write a multilayered JSP application to read and store employee Information in Database.


5. Write a multilayered JSP application to read and store employee information. Read employee name, employee identification number, Department, Designation, Basic Salary, TA, DA, HRA, PF, LIC (in percentage) as input through a proper user interface page. Also calculate TA Amount, DA Amount, HRA Amount, PF Amount, LIC Amount, Total Allowances, Total Deductions, Gross Salary and Net Salary components of the employee. Along with the employee information store the salary details in the MS Access table.
Code for Emp13.html:
<!-- 13. HTML Program to accept Employee Details. -->
<html>
 <head>

 <title>Employee Details</title>
 </head>
 <body>
 <h3>Enter Employee Details:</h3>
 <form action="Emp13.jsp" method="POST" >
 <table >
 <tr><td>Employee Name:</td><td><input type="text" name="ename" ></td></tr>
 <tr><td>Employee ID:</td><td><input type="text" name="empid"></td></tr>
 <tr><td>Department:</td><td><input type="text" name="dept"></td></tr>
 <tr><td>Designation:</td><td><input type="text" name="des"></td></tr>
 <tr><td>Basic Salary:</td><td><input type="text" name="bsal"></td></tr>
 <tr><td>TA(%):</td><td><input type="text" name="ta"></td></tr>
 <tr><td>DA(%):</td><td><input type="text" name="da"></td></tr>
 <tr><td>HRA(%):</td><td><input type="text" name="hra"></td></tr>
 <tr><td>PF(%):</td><td><input type="text" name="pf"></td></tr>
 <tr><td>LIC(%):</td><td><input type="text" name="lic"></td></tr>

 <tr><td><input type="submit" value="Evaluate & Store"></td>
 <td><input type="reset" value="Reset"></td></tr>
 </table>
 </form>
 </body>
</html>

Code for Emp13.jsp:
<!-- 13. JSP Program to Evaluate Salary Details of an Employee and Store in Database.-->
<html>
<head>
<%@ page import="java.sql.*" %>
</head>
<body bgcolor="beige">

<%
  
    String ename=request.getParameter("ename");
    String empid=request.getParameter("empid");
    String dept=request.getParameter("dept");
    String des=request.getParameter("des");
    double bsal=Double.valueOf(request.getParameter("bsal"));
    double ta=Double.valueOf(request.getParameter("ta"));
    double ta2=bsal*ta/100;
    double da=Double.valueOf(request.getParameter("da"));
    double da2=bsal*da/100;
    double hra=Double.valueOf(request.getParameter("hra"));
    double hra2=bsal*hra/100;
    double pf=Double.valueOf(request.getParameter("pf"));
    double pf2=bsal*pf/100;
    double lic=Double.valueOf(request.getParameter("lic"));
    double lic2=bsal*lic/100;
    double allowance;
    double deduction;
    double gsal;
    double netsal;

    allowance = (bsal*ta)/100 + (bsal*da)/100 + (bsal*hra)/100;
    deduction = (bsal*pf)/100 + (bsal*lic)/100;
    gsal = bsal + allowance;
    netsal = gsal - deduction;
  
    try
    {
        out.println("<h2>Information Stored Successfully!</h2>");
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Connection con=DriverManager.getConnection("jdbc:odbc:emp13");
        Statement st=con.createStatement();
        String s="insert into emp13 values('"+ename+"','"+empid+"','"+dept+"','"+des+"',"
            +bsal+","+allowance+","+gsal+","+deduction+","+netsal+");";
        st.executeQuery(s);
    }
    catch(Exception e)
    {
        //out.println(e);
    }
%>
</body>
</html>

4. Write a multilayered JSP application to accept and store student information in Database..


4. Write a multilayered JSP application to accept and store student information. Accept student name, register number, course, combination, semester, marks obtained in five subjects as input through a proper user interface page. Design course, combination and semester as combo boxes. Store the accepted details in the MS Access table.
Code for Stud12.html:
<!-- 12. Program to read student info. and store into database -->
<html>
 <head>

 <title>Student Information</title>
 </head>
 <body>
 <h3>Enter Student Details:</h3>
 <form action="Stud12.jsp" method="POST" >
 <table >
 <tr><td>Name:</td><td><input type="text" name="sname"></td></tr>
 <tr><td>Register Number:</td><td><input type="text" name="regno"></td></tr>
 <tr><td>Course:</td><td>    <select name="course">
                            <option >BCA</option>
                            <option >BSc</option>
                            <option >BA</option>
                            </select> </td></tr>

 <tr><td>Combination:</td><td>    <select name="comb">
                            <option >Computer Applications</option>
                            <option >PMCs</option>
                            <option >EMCs</option>
                            <option >HSP</option>
                            <option >HEK</option>
                            </select> </td></tr>
 <tr><td>Semester:</td><td>    <select name="sem">
                            <option >I</option>
                            <option >II</option>
                            <option >III</option>
                            <option >IV</option>
                            <option >V</option>
                            <option >VI</option>
                            </select> </td></tr>
 <tr><td>Sub1:</td><td><input type="text" name="sub1"></td></tr>
 <tr><td>Sub2:</td><td><input type="text" name="sub2"></td></tr>
 <tr><td>Sub3:</td><td><input type="text" name="sub3"></td></tr>
 <tr><td>Sub4:</td><td><input type="text" name="sub4"></td></tr>
 <tr><td>Sub5:</td><td><input type="text" name="sub5"></td></tr>

 <tr><td><input type="submit" value="Save in Database" ></td>
 <td><input type="reset" value="Reset" ></td></tr>
 </table>
 </form>
 </body>
</html>
Code for Stud12.jsp:
<!-- 12. JSP Program to Store Student Information in the Database. -->
<html>
<head>
<title>Student Information</title>
<%@page import="java.sql.*,java.util.*"%>
</head>
<body>
<%
    String sname=request.getParameter("sname");
    String regno=request.getParameter("regno");
    String course=request.getParameter("course");
    String comb=request.getParameter("comb");
    String sem=request.getParameter("sem");
    int sub1=Integer.parseInt(request.getParameter("sub1"));
    int sub2=Integer.parseInt(request.getParameter("sub2"));
    int sub3=Integer.parseInt(request.getParameter("sub3"));
    int sub4=Integer.parseInt(request.getParameter("sub4"));
    int sub5=Integer.parseInt(request.getParameter("sub5"));
  
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbc:odbc:stud12");
    Statement st=con.createStatement();
    try
    {
        out.println("<h3>Data Saved Successfully!</h3>");
        String s="insert into stud12 values('"+sname+"','"+regno
            +"','"+course+"','"+comb+"','"+sem+"',"+sub1
            +","+sub2+","+sub3+","+sub4+","+sub5+");";
        st.executeQuery(s);
      
    }
    catch(Exception e)
    {
        //out.println("Insertion of data failed!");
        //out.println(e);
    }
%>
</body>
</html>
FREE Hit Counters