-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemp.php
61 lines (58 loc) Β· 2.01 KB
/
temp.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
session_start();
error_reporting(0);
include('includes/config.php');
if(strlen($_SESSION['login'])==0)
{
header('location:index.php');
}
else{
$StudentID=$_GET['StudentID'];
$StudName=$_GET['StudName'];
$ISBNNumber=$_GET['ISBNNumber'];
$BookName=$_GET['BookName'];
$AuthorName=$_GET['AuthorName'];
$CategoryName=$_GET['CategoryName'];
$BookPrice=$_GET['BookPrice'];
$sql = "SELECT * from tblrequestedbookdetails where StudentID=:StudentID and ISBNNumber=:ISBNNumber";
$query = $dbh -> prepare($sql);
$query->bindParam(':StudentID',$StudentID,PDO::PARAM_STR);
$query->bindParam(':ISBNNumber',$ISBNNumber,PDO::PARAM_STR);
$query->execute();
$results=$query->fetchAll(PDO::FETCH_OBJ);
$cnt=1;
if($query->rowCount() > 0)
{
$_SESSION['msg']="You have already requested this book";
header('location:request-a-book.php');
}
else{
$sql = "SELECT * from tblrequestedbookdetails where StudentID=:StudentID";
$query = $dbh -> prepare($sql);
$query->bindParam(':StudentID',$StudentID,PDO::PARAM_STR);
$query->execute();
$results=$query->fetchAll(PDO::FETCH_OBJ);
$cnt=1;
if($query->rowCount() == 2)
{
$_SESSION['msg']="You cannot request more than 2 books at a time";
header('location:request-a-book.php');
}
else
{
$sql="INSERT INTO tblrequestedbookdetails(StudentID,StudName,BookName,CategoryName,AuthorName,ISBNNumber,BookPrice) VALUES(:StudentID,:StudName,:BookName,:CategoryName,:AuthorName,:ISBNNumber,:BookPrice)";
$query = $dbh->prepare($sql);
$query->bindParam(':StudentID',$StudentID,PDO::PARAM_STR);
$query->bindParam(':StudName',$StudName,PDO::PARAM_STR);
$query->bindParam(':BookName',$BookName,PDO::PARAM_STR);
$query->bindParam(':CategoryName',$CategoryName,PDO::PARAM_STR);
$query->bindParam(':AuthorName',$AuthorName,PDO::PARAM_STR);
$query->bindParam(':ISBNNumber',$ISBNNumber,PDO::PARAM_STR);
$query->bindParam(':BookPrice',$BookPrice,PDO::PARAM_STR);
$query->execute();
$lastInsertId = $dbh->lastInsertId();
$_SESSION['msg']="Book requested successfully";
header('location:request-a-book.php');
}
}
}?>