-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpaperlist.php
More file actions
39 lines (37 loc) · 1.33 KB
/
paperlist.php
File metadata and controls
39 lines (37 loc) · 1.33 KB
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
<?php
//include('dbconfig.php');
include('session.php');
if(isset($_SESSION['current_user'])){
if($_SESSION['current_user'] == 'rohan'){
?>
<form action = "" method = "POST">
<input type="text" name = "title" />
<input type="submit" name="submit" value="Register" />
</form>
<?php
if(isset($_POST['title']) and $_POST['title'] != ""){
$title = $_POST['title'];
$sql = "INSERT INTO papers(title) values('$title')";
if(mysqli_query($conn, $sql) == TRUE){
header("location: paperlist.php");
}
else{
echo "Error: " . $sql . "<br>" . $conn->error;
}
}
}
$sql = "SELECT * FROM papers order by id";
$resultset = mysqli_query($conn, $sql); // query execution
if($resultset){
echo "<table border=1><tr><th>Paper list</th></tr>";
$ln = 0;
while($row = mysqli_fetch_assoc($resultset)){// returns the current row of the resultset
$id = $row['id'];
$fname = $row['title'];
$ln++;
echo "<tr><td> ",$ln,") <a href = './paper.php?id=$id&fname=$fname' target = '_blank'>$fname</a></td></tr>";
}
echo "</table>";
}
}
?>