Professional Documents
Culture Documents
Installation steps:
Tomcat7 Installation:
1. If not install java by following commands:
$ add-apt-repository ppa:webupd8team/java
$ apt-get update
$ apt-get install oracle-java8-installer
$ java -version
2. Install Tomcat server
Xampp Installation:
4) You to need to Change the directory to where the file is downloaded.By defalut it
is Downloads Folder.Type the following command in terminal.
cd ~/Downloads
Note:- If you Don't change the Directory path to Downloads folder it will throw the
following error "chmod: cannot access ‘xampp-linux-x64-1.8.3-2-installer.run’: No such
file or directory" .So to avoid this error change the directory path using Step 4.
Input code:
//assig_8.php
<?php
$con = mysqli_connect("localhost","root","","test");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$fname = '';
$lname = '';
$roll = '';
//insert query
if (isset($_POST['insert'])) {
$fname = $_POST["fname"];
$lname = $_POST["lname"];
$roll = $_POST["roll"];
if (empty($fname)) {
echo "enter first name";
}elseif (empty($lname)) {
echo "enter last name";
}elseif (empty($roll)) {
echo "enter roll number";
}else
if (isset($_POST['display'])) {
$sql = 'SELECT * FROM studdb';
$result = mysqli_query($con, $sql);
if ($result && mysqli_num_rows($result) > 0)
{ while($row = mysqli_fetch_assoc($result))
}
} else {
echo "0 results";
}
}
//update query
if (isset($_POST['update'])) {
$fname = $_POST["fname"];
$lname = $_POST["lname"];
$roll = $_POST["roll"];
if(empty($roll))
{
echo 'enter user roll number to update';
} else{
$sql = "UPDATE `studdb` SET fname = '$fname', lname = '$lname', roll = '$roll'
WHERE roll = '$roll' ";
if (mysqli_query($con, $sql)) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . mysqli_error($con);
}
}
}
//delete query
if (isset($_POST['delete'])) {
$roll = $_POST["roll"];
if(empty($roll))
{
echo 'enter roll number to delete';
} else{
if (mysqli_query($con, $sql)===true) {
echo "Record deleted successfully";
} else {
echo "Error deleting record: " .
mysqli_error($con); }
}
}
?>
//assig_8.html
<!DOCTYPE html>
<html>
<head>
<title>Basic CRUD </title>
<link rel="stylesheet" type="text/css" href="design.css">
</head>
<body>
<form action="assig_8.php" method="POST">
<div class="complete">
<div align="center" class="heading">
<h1>Student Data Base</h1>
</div>
<div align="center" class="text">
<div class="field">
<input type="text" name="fname" placeholder="first name"><br><br>
<input type="text" name="lname" placeholder="lastname"><br><br>
<input type="number" name="roll" placeholder="ROLL NUMBER"><br><br>
</div>
<div class="button">
<input type="submit" name="insert" value="Insert">
<input type="submit" name="display" value="Display All">
<input type="submit" name="update" value="Update"> <input
</div>
</div>
</div>
</form>
</body>
</html>
Output:
Student Data Base
ABC