Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions End Term Practicals/IT/27_2013741_Shivam_Singh/connect.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
$hostName = '127.0.0.1';
$userName = 'root';
$password = '';
$databaseName = 'BookStore';

$conn = mysqli_connect($hostName, $userName, $password, $databaseName);

if($conn){
}
else{
echo mysqli_error();
}

?>
61 changes: 61 additions & 0 deletions End Term Practicals/IT/27_2013741_Shivam_Singh/q2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php
include('config.php');
?>

<!-- Code to fetch data -->
<?php

$sql="SELECT * FROM users";
$result=mysqli_query($conn, $sql);

if($result!==false && $result->num_rows > 0){
?>

<table border="1px">
<thead>
<tr>
<th>BOOK ID</th>
<th>Book Name</th>
<th>Author</th>
<th>ISBN</th>
<th>Publisher</th>
<th>Publiction Year</th>
<th>Pages</th>
<th>Book Type</th>

</tr>
</thead>
<tbody>
<?php
while($row = $result->fetch_array()){?>
<tr>
<td><?php echo $row[0]?></td>
<td><?php echo $row[1]?></td>
<td><?php echo $row[2]?></td>
<td><?php echo $row[3]?></td>
<td><?php echo $row[4]?></td>
<td><?php echo $row[5]?></td>
<td><?php echo $row[6]?></td>
<td><?php echo $row[7]?></td>
<td><a href="edit.php?id=<?php echo $row[0]?>">
<input type="button" value="Edit"></a></td>
<td><input type="button" value="delete"></td>

</tr>
<?php } ?>
</tbody>
</table>
<?php }
?>


<html>

<head>

<title>User Details</title>
</head>
<body>

</body>
</html
94 changes: 94 additions & 0 deletions End Term Practicals/IT/27_2013741_Shivam_Singh/question_1.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php
require_once('config.php');

?>

<?php
$showAlert=false;
if($_SERVER["REQUEST_METHOD"]=="POST"){
include('config.php');
$bname = $_POST['bname'];
$aname = $_POST['aname'];
$isbn = $_POST['isbn'];
$pname = $_POST['pname'];
$sql = "INSERT INTO `users` (`bname`, `aname`, `isbn`, `pname`) VALUES ('$bname', ' $aname', '$isbn', ' $pname')";
$result=mysqli_query($conn, $sql);
if($result){
$showAlert=true;
header('location:details.php');
}
else{
echo "there was an error";
}
}

?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>

</head>
<body>
<?php
if($showAlert)
{
echo '<div class="alert alert-success" role="alert">
Successfully inserted!
</div>';
}
?>
<div class="container">
<html>
<head>
<title>
Book
</title>
</head>
<body>
<form method="POST" action="form.php">
Book Name <input type="text" placeholder="Enter Book Name" name="bname"><br><br>
Author Name <input type="text" placeholder="Enter Author Name" name="aname"><br><br>
ISBN Number <input type="text" placeholder="Enter ISBN Number" name="isbn"><br><br>
Publisher Name <input type="text" placeholder="Enter Publisher Name" name="pname"><br><br>
<br>Publication Year<br>
<select name="pyear">
<option value="2010">2010</option>
<option value="2011">2011</option>
<option value="2012">2012</option>
<option value="2013">2013</option>
<option value="2014">2014</option>
<option value="2015">2015</option>
<option value="2016">2016</option>
<option value="2017">2017</option>
<option value="2018">2018</option>
<option value="2019">2019</option>
<option value="2020">2020</option>
<option value="2021">2021</option>
</select><br>
<br> Book Type <br>
Action <input type="radio" value="Action" name="btype"><br>
Adventure <input type="radio" value="Adventure" name="btype"><br>
Classics <input type="radio" value="Classics" name="btype"><br>
Comic Book <input type="radio" value="Comic_Book" name="btype"><br>
Graphic Novel <input type="radio" value="Graphic_Novel" name="btype"><br>
Detective <input type="radio" value="Detective" name="btype"><br>
Mystery <input type="radio" value="Mystery" name="btype"><br>
Historical Fiction <input type="radio" value="Historical_Fiction" name="btype"><br>
Horror <input type="radio" value="Horror" name="btype"><br>
Literary Fiction <input type="radio" value="Literary_Fiction" name="btype"><br>
<br>
Number Of Pages<br>
<input type="range" name="volume" min="200" max="400"> <br><br>
<input type="submit" name="submit">
</form>


</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>


</body>
</html>
28 changes: 28 additions & 0 deletions End Term Practicals/IT/27_2013741_Shivam_Singh/second.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
include_once('connect.php');
?>
<?php
if(isset($_POST['submit'])){
$bookname = $_POST['bname'];
$authorname = $_POST['aname'];
$isbn = $_POST['isbn'];
$pubname = $_POST['pname'];
$pubyear = $_POST['pyear'];
$booktype = $_POST['btype'];
$no = $_POST['volume'];

$sql = "INSERT INTO `books` (Book_name, Author_name, ISBN_number, Pub_name,Pub_year,Book_type,Pages)
VALUES ('$bookname', '$authorname', '$isbn', '$pubname','$pubyear','$booktype','$no')";

if(mysqli_query($conn, $sql)){
echo 'Data inserted successfully...';
// header("Location:details.php");
}
else{
echo 'Data insertion failed...'.mysqli_error($conn) ;
}
}
else{
echo "Please go back to Input Page.";
}
?>