forked from marcokuang/cs174hw3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddToDo.php
More file actions
54 lines (53 loc) · 1.78 KB
/
AddToDo.php
File metadata and controls
54 lines (53 loc) · 1.78 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!DOCTYPE html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="contents">
<header id="header" class="header">
<h1 align="center">Add New Classes</h1>
<div style="text-align:center; padding:30px;">
<a href="addEntry.php">Show ToDoTable</a>
</div>
</header><!-- /header -->
<section id="result" align="center">
<?php
$StudentID = filter_input(INPUT_POST, "StudentID");
$ClassID = filter_input(INPUT_POST, "ClassID");
$ToDo = filter_input(INPUT_POST, "ToDo");
$Password = filter_input(INPUT_POST, "Password");
print $StudentID;
print $ClassID;
print $ToDo;
define("HOSTNAME", "localhost");
define("DATABASENAME", "Developers");
define("DATABASEUSER", "root");
define("PASSWORD", "Marco1991");
try {
// Create connection
$con = new PDO("mysql:host=".HOSTNAME.";dbname=".DATABASENAME,DATABASEUSER,PASSWORD);
// set the PDO error mode to exception
$con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$query =
"INSERT INTO ToDoTable
(StudentID, ClassID, ToDo)
VALUES ($StudentID, '$ClassID', '$ToDo')";
// use exec() because no results are returned
$data = $con->exec($query);
echo "New record created successfully";
}
catch(PDOException $e) {
echo $query . "<br>" . $e->getMessage();
} $con = null;
//header('Location: CheckLogIn.php');
print "<form method=\"post\" action=\"CheckLogIn.php\">";
print "<input type=\"hidden\" name=\"StudentID\" value=\"$StudentID\">";
print "<input type=\"hidden\" name=\"Password\" value=\"$Password\">";
print "<input type=\"submit\" value=\"Return\">";
print "</form>";
?>
</p>
</section>
</div>
</body>
</html>