0% found this document useful (0 votes)
26 views17 pages

SMSText

Uploaded by

Ashu jadhav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views17 pages

SMSText

Uploaded by

Ashu jadhav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 17

index.

jsp______________________________________________________

<%@ page import="java.sql.*" %>


<html lang="en">

<head>
<meta charset="UTF-8">
<title> Student Management System </title>
<link rel="stylesheet" href="styles.css" />
</head>

<body>
<div class="header">
<br><br><h1>STUDENT MANAGEMENT SYSTEM</h1>
</div>

<div class="container">
<div class="form-container">
<p class="sign-in-text">Sign in to continue</p><br>
<form method="post">
<div class="form-group">
<input type="username" name="username" placeholder="Username"
required /><br><br>
</div>

<div class="form-group">
<input type="password" name="password" placeholder="Password"
required /><br>
</div>

<div class="form-group">
<input type="submit" name="btn" value="Login" />
</div>

<div class="signin-link">
<p>Don't have an account? <a href="signup.jsp">Sign Up</a></p>
</div>
</form>
<%
if(request.getParameter("btn") != null)
{
String username = request.getParameter("username");
String password = request.getParameter("password");
try{
DriverManager.registerDriver(new
com.mysql.cj.jdbc.Driver());
String url = "jdbc:mysql://localhost:3306/SMS";
Connection con =
DriverManager.getConnection(url,"root","abc123");
String sql = "select * from login where username=?
and password=?";
PreparedStatement pst = con.prepareStatement(sql);
pst.setString(1, username);
pst.setString(2, password);
ResultSet rs = pst.executeQuery();
if(rs.next()){
session.setAttribute("username", username);
response.sendRedirect("sms.jsp");
}else{
%>
<script>
window.onload = function() {
alert("Invalid login");
};
</script>
<%
}
con.close();
}catch(SQLException e){
out.println("issue "+e);
}
}
%>
</div>
</div>
</body>
</html>

signup.jsp______________________________________________________
<%@ page import="java.sql.*" %>
<html lang="en">

<head>
<meta charset="UTF-8">
<title> Student Management System </title>
<link rel="stylesheet" href="styles.css" />
</head>

<body>
<center>

<div class="header">
<br><br><h1>STUDENT MANAGEMENT SYSTEM</h1>
</div>

<div class="container">
<div class="form-container">
<p class="sign-in-text">Sign in to continue</p><br>
<form method="post">
<div class="form-group">
<input type="username" name="username" placeholder="
Username" pattern="^[A-Za-z]{2,}$" title="Please enter min 2 Alphabets, no special
chars and numbers to be inserted." required onchange="this.value =
this.value.trim()">
<br><br>
<input type="password" name="password" placeholder="
Password" required onchange="this.value = this.value.trim()">
<br><br>
<input type="password" name="repeat"
placeholder="Repeat Password" required onchange="this.value = this.value.trim()">
<br><br>
<div class="form-group">
<input type="submit" name="btn"
value="Sign Up" />
</div>
</div>
<div class="signin-link">
<p>Already have an account?<a href="index.jsp">Sign
In</a></p>
</div>
</form>
<%
if(request.getParameter("btn") != null) {
String username = request.getParameter("username");
String password = request.getParameter("password");
String repeat = request.getParameter("repeat");
if(password.equals(repeat)) {
try {
DriverManager.registerDriver(new
com.mysql.cj.jdbc.Driver());
String url = "jdbc:mysql://localhost:3306/SMS";
Connection con =
DriverManager.getConnection(url,"root","abc123");
String sql = "insert into login (username, password) values
(?, ?)";
PreparedStatement pst = con.prepareStatement(sql);
pst.setString(1, username);
pst.setString(2, password);
pst.executeUpdate();
con.close();
%>
<script>
window.onload = function() {
alert("Signup Successful");
window.location.replace("index.jsp");
};
</script>
<%
} catch(Exception e) {
out.println("issue "+e);
}
} else {
%>
<script>
window.onload = function() {
alert("Passwords do not match, Please try again.");
};
</script>
<%
}
}
%>

</div>
</div>
</center>
</body>
</html>
sms.jsp______________________________________________________
<%@ page import="java.sql.*" %>
<html lang="en">

<head>
<meta charset="UTF-8">
<title> Student Management System </title>
<link rel="stylesheet" href="sms.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-
awesome/4.7.0/css/font-awesome.min.css">

</head>

<body>
<center>
<div class="container">
<div class="header">
<h1>Student Management System</h1>
</div>

<div class="menu">
<br> <a href="add.jsp"><button type="button" class="btn btn1"><i
class="fa fa-plus"></i> Add Student </button></a>
<br>
<a href="view.jsp"><button type="button" class="btn btn2"><i
class="fa fa-search"></i> View Student </button></a>
<br>
<a href="update.jsp"><button type="button" class="btn btn4"><i
class="fa fa-edit"></i> Update Student </button></a>
<br>
<a href="delete.jsp"><button type="button" class="btn btn3"><i
class="fa fa-trash"></i> Delete Student </button></a>
<br><br>
<a href="index.jsp"><button type="button" class="open-button"><i
class="fa fa-arrow-left"></i> Logout </button></a>
</div>
</div>
</center>
</body>

</html>

sms.css______________________________________________________
/* Add the styles from styles.css and sms.jsp here */

body {
font-family: Arial, Helvetica, sans-serif;
background-color: orange;
margin: 0;
padding: 0;
}

.container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 90vh;
}

.header {
text-align: center;
margin-bottom: 60px;
}

.header h1 {
font-size: 48px;
font-weight: bold;
margin: 0;
color: blue;
font-family: "Georgia";
text-transform: uppercase;
}

.sign-in-text {
color: orangered;
font-weight: bold;
text-align: center;
}

.form-container {
background-color: rgb(253, 188, 67);
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
max-width: 400px;
width: 100%;
}

.form-group {
margin-bottom: 20px;
}

.form-group input[type="username"],
.form-group input[type="password"] {
width: 100%;
padding: 10px;
font-size: 16px;
border: 1px solid #ccc;
background: #f3deb8;
color: gray;
outline: none;
}

.form-group input[type="submit"] {
width: 100%;
padding: 10px;
font-size: 18px;
font-weight: bold;
color: white;
background-color: #007bff;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s;
}

.form-group input[type="submit"]:hover {
background-color: #00a3ff;
}

.signin-link {
text-align: right;
font-size: 10px;
}

.signin-link a {
color: blue;
font-size: 18px;
text-decoration: none;
}

.signin-link a:hover {
color: blue;
font-weight: bold;
}

.link-button {
text-decoration: none;
}

.menu {
text-align: center;
}

.btn {
background-color: #4CAF50;
color: white;
border: none;
padding: 15px 20px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 20px;
margin: 10px 0;
cursor: pointer;
border-radius: 5px;
}

.btn:hover {
background-color: blue;
}

.btn1 {
background-color: #f44336;
}

.btn2 {
background-color: #2196F3;
}
.btn3 {
background-color: #f44336;
}

.btn4 {
background-color: #FF9800;
}

.open-button {
background-color: #4CAF50;
color: white;
padding: 15px 20px;
border: none;
cursor: pointer;
border-radius: 5px;
font-size: 20px;
}

.open-button:hover {
background-color: green;
}

.fa {
margin-right: 10px;
font-size: 20px;
}

.menu {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}

.menu button {
margin: 5px 0;
}

add.jsp______________________________________________________
<%@ page import="java.sql.*" %>
<html lang="en">

<head>
<meta charset="UTF-8">
<title> Student Management System </title>
<link rel="stylesheet" href="styles.css" />
</head>

<body>
<center>
<form>
<div class="header">
<br><br> <h1>Add Students</h1>
</div>
<div class="form-container">
<div class="addjsp">
<label for="rollno"><b>Roll No: </b></label>
<input type="number" name="rollno" placeholder=" Roll No" required
min="1">
</div>
<br>

<div class="addjsp">
<label for="username"><b>Name: </b></label>
<input type="text" name="username" placeholder=" User Name"
pattern="^[A-Za-z ]{2,}$"
title="Please enter min 2 Alphabets, no special chars and
numbers to be inserted." required
onchange="this.value = this.value.trim()">
</div>
<br>

<div class="addjsp">
<label for="marks"><b>Marks: </b></label>
<input type="number" name="marks" placeholder=" Marks" required
min="0" max="100">
</div>
<br>

<div class="addjsp">
<button type="submit" class="open-button"
name="btn">Save</button><br><br>
<a href="sms.jsp"><button type="button"
class="open-button">Back</button></a>
</div>
</form>

<%
if (request.getParameter("btn") != null) {
try {
DriverManager.registerDriver(new com.mysql.cj.jdbc.Driver());
String url = "jdbc:mysql://localhost:3306/SMS";
Connection con = DriverManager.getConnection(url, "root",
"abc123");

int rollno = Integer.parseInt(request.getParameter("rollno"));


String checkRollnoSql = "SELECT * FROM students WHERE
rollno=?";
PreparedStatement checkRollnoPst =
con.prepareStatement(checkRollnoSql);
checkRollnoPst.setInt(1, rollno);
ResultSet rs = checkRollnoPst.executeQuery();
if(rs.next()) {
%>
<script>
alert("Roll No already exists.");
</script>
<%
} else {
String insertSql = "INSERT INTO students VALUES (?, ?, ?)";
PreparedStatement insertpst =
con.prepareStatement(insertSql);
String username = request.getParameter("username");
double marks =
Double.parseDouble(request.getParameter("marks"));

insertpst.setInt(1, rollno);
insertpst.setString(2, username);
insertpst.setDouble(3, marks);
insertpst.executeUpdate();
%>
<script>
alert("Record Created");
</script>
<%
}
con.close();
} catch (SQLException e) {
out.println("issue " + e);
}
}
%>
</div>
</center>
</body>
</html>

view.jsp______________________________________________________
<%@ page import="java.sql.*" %>

<html lang="en">

<head>
<meta charset="UTF-8">
<title> Student Management System </title>
<link rel="stylesheet" href="styles.css" />
</head>

<body>
<center>
<br><br><div class="header">
<h1>View Student</h1>
</div>
<div class="container">
<table class="table">
<tr>
<th>Roll No</th>
<th>Name</th>
<th>Marks</th>
</tr>
<%
try{
DriverManager.registerDriver(new com.mysql.cj.jdbc.Driver());
String url = "jdbc:mysql://localhost:3306/SMS";
Connection con = DriverManager.getConnection(url, "root",
"abc123");
String sql = "select * from students";
PreparedStatement pst = con.prepareStatement(sql);
ResultSet rs = pst.executeQuery();

while(rs.next()){
%>
<tr>
<td><%= rs.getInt(1) %></td>
<td><%= rs.getString(2) %></td>
<td><%= rs.getDouble(3) %></td>
</tr>
<%
}
con.close();
}catch(SQLException e){
out.println("issue "+e);
}
%>
</table>
<br><br>
<a href="sms.jsp"><button type="button"
class="open-button">Back</button></a>
</div>
</center>
</body>

</html>

update.jsp______________________________________________________
<%@ page import="java.sql.*" %>
<html lang="en">

<head>
<meta charset="UTF-8">
<title> Student Management System </title>
<link rel="stylesheet" href="styles.css" />
</head>

<body>
<center>
<form onsubmit="return confirmUpdate();">
<div class="header">
<br><br> <h1>Update Students</h1>
</div>

<div class="form-container"><br>
<div class="updatejsp">
<label for="rollno"><b>Roll No:</b></label>
<input type="number" name="rollno" placeholder=" Roll No" required
min="1">
</div>
<br>

<div class="updatejsp">
<label for="username"><b>Name:</b></label>
<input type="text" name="username" placeholder=" User Name"
pattern="^[A-Za-z]{2,}$"
title="Please enter min 2 Alphabets, no special chars and
numbers to be inserted." required
onchange="this.value = this.value.trim()">
</div>
<br>

<div class="updatejsp">
<label for="marks"><b>Marks:</b></label>
<input type="number" name="marks" placeholder=" Marks" required
min="0" max="100">
</div>
<br>

<div class="updatejsp">
<button type="submit" class="open-button"
name="btn">Update</button><br><br>
<a href="sms.jsp"><button type="button"
class="open-button">Back</button></a>
</div>
</form>
<%
if(request.getParameter("btn") != null)
{
try{
DriverManager.registerDriver(new
com.mysql.cj.jdbc.Driver());
String url = "jdbc:mysql://localhost:3306/SMS";
Connection con = DriverManager.getConnection(url, "root",
"abc123");

int rollno =
Integer.parseInt(request.getParameter("rollno"));
String checkRollnoSql = "SELECT * FROM students WHERE
rollno=?";
PreparedStatement checkRollnoPst =
con.prepareStatement(checkRollnoSql);
checkRollnoPst.setInt(1, rollno);
ResultSet rs = checkRollnoPst.executeQuery();
if (!rs.next()) {
%>
<script>
window.onload = function() {
alert("Roll No does not exists. Please try
again.");
};
</script>
<%
}else{
String updatesql = "update students set name=?,
marks=? where rollno=?";
PreparedStatement updatepst =
con.prepareStatement(updatesql);

String username = request.getParameter("username");


double marks =
Double.parseDouble(request.getParameter("marks"));

updatepst.setString(1, username);
updatepst.setDouble(2, marks);
updatepst.setInt(3,rollno);
int r = updatepst.executeUpdate();
%>
<script>
window.onload = function() {
alert("Record Updated");
};
</script>
<%
}
con.close();
}catch(SQLException e){
out.println("issues "+e);
}
}
%>
<script>
function confirmUpdate() {
return confirm("Are you sure you want to Update this record?");
}
</script>
</div>
</center>
</body>
</html>

delete.jsp______________________________________________________
<%@ page import="java.sql.*" %>

<html lang="en">

<head>
<meta charset="UTF-8">
<title> Student Management System </title>
<link rel="stylesheet" href="styles.css" />
</head>

<body>
<center>
<form onsubmit="return confirmDelete();">
<div class="header">
<br><br> <h1>Delete Student</h1>
</div>
<div class="form-container">
<div class="deletejsp"><br>
<label for="rollno"><b>Roll No: </b></label>
<input type="number" name="rollno" placeholder=" Roll No" required>
</div>
<br>

<div class="deletejsp">
<button type="submit" class="open-button"
name="btn">Delete</button><br><br>
<a href="sms.jsp"><button type="button"
class="open-button">Back</button></a>
</div>
</form>
<%
if (request.getParameter("btn") != null) {
try {
DriverManager.registerDriver(new com.mysql.cj.jdbc.Driver());
String url = "jdbc:mysql://localhost:3306/SMS";
Connection con = DriverManager.getConnection(url, "root",
"abc123");

int rollno = Integer.parseInt(request.getParameter("rollno"));


String checkRollnoSql = "SELECT * FROM students WHERE
rollno=?";
PreparedStatement checkRollnoPst =
con.prepareStatement(checkRollnoSql);
checkRollnoPst.setInt(1, rollno);
ResultSet rs = checkRollnoPst.executeQuery();
if (!rs.next()) {
%>
<script>
alert("Roll No does not exist. Please try again.");
</script>
<%
} else {
String deletesql = "delete from students where rollno=?";
PreparedStatement deletepst =
con.prepareStatement(deletesql);

deletepst.setInt(1, rollno);
int r = deletepst.executeUpdate();
%>
<script>
alert("Record Deleted");
</script>
<%
}
con.close();
} catch (SQLException e) {
out.println("issues "+e);
}
}
%>
<script>
function confirmDelete() {
return confirm("Are you sure you want to delete this record?");
}
</script>
</div>
</center>
</body>
</html>

styles.css______________________________________________________
body {
font-family: Arial, Helvetica, sans-serif;
background-color: orange;
margin: 0;
padding: 0;
}

.container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 80vh;
}

.header {
text-align: center;
margin-bottom: 10px;
}

.header h1 {
font-size: 48px;
font-weight: bold;
margin: 0;
color: blue;
font-family: "Georgia";
text-transform: uppercase;
}

.sign-in-text {
color: orangered;
font-weight: bold;
text-align: center;
}

.form-container {
margin-top: 70px;
background-color: rgb(253, 188, 67);
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
max-width: 400px;
width: 100%;
}

.form-group {
margin-bottom: 20px;
}

.form-group input[type="username"],
.form-group input[type="password"] {
width: 100%;
padding: 10px;
font-size: 16px;
border: 1px solid #ccc;
background: #f3deb8;
color: gray;
outline: none;
}
.form-group input[type="submit"] {
width: 100%;
padding: 10px;
font-size: 18px;
font-weight: bold;
color: white;
background-color: #007bff;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s;
}

.form-group input[type="submit"]:hover {
background-color: #00a3ff;
}

.signin-link {
text-align: right;
font-size: 10px;
}

.signin-link a {
color: blue;
font-size: 18px;
text-decoration: none;
}

.signin-link a:hover {
color: blue;
font-weight: bold;
}

.addjsp,
.deletejsp,
.updatejsp {
margin-bottom: 20px;
}

.addjsp input[type="number"],
.addjsp input[type="text"],
.deletejsp input[type="number"],
.updatejsp input[type="number"],
.updatejsp input[type="text"] {
width: 100%;
padding: 10px;
font-size: 16px;
border: 1px solid #ccc;
background: #f3deb8;
color: gray;
outline: none;
}
.addjsp button[type="submit"],
.deletejsp button[type="submit"],
.updatejsp button[type="submit"] {
width: 100%;
padding: 15px 30px;
font-size: 18px;
font-weight: bold;
color: white;
background-color: #007bff;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s;
}

.addjsp button[type="submit"]:hover,
.deletejsp button[type="submit"]:hover,
.updatejsp button[type="submit"]:hover {
background-color: red;
}

.addjsp a,
.deletejsp a,
.updatejsp a {
text-decoration: none;
}

a {
text-decoration: none;
color: black;
}

.open-button {
background-color: #007bff;
color: white;
padding: 10px 20px;
border: none;
cursor: pointer;
border-radius: 5px;
font-size: 16px;
}

.open-button:hover {
background-color: red;
}

.fa {
margin-right: 5px;
}

.table {
width: 60%;
border-collapse: collapse;
border: 1px solid black;
}

.table th, .table td {


padding: 10px;
text-align: center;
border: 1px solid black;

.table th {
background-color: orangered; /* Added background color for table header */
font-weight: bold;
}

You might also like