-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddstud.php
48 lines (38 loc) · 1018 Bytes
/
addstud.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
<?php
session_start();
#echo $_SESSION['stud_id']; #works
$host='localhost';
include 'rootpass.php';
$db='Moodle';
$con=mysqli_connect($host,$user,$pass,$db);
if (!$con){
echo "Couldn't connect Database.";
}
#echo "Database ".$db." Connected successfully\n";
?>
<html>
<head><title>Add Students</title>
</head>
<body>
<h1> Add Student</h1>
<p> Fill the corresponding blanks</p>
<br>
<?php
if ($_POST['id']){
$id=$_POST['id'];
$pass=$_POST['pass'];
$name=$_POST['name'];
$sql="insert into studs values($id,'$pass','$name',NULL,NULL,NULL,NULL,NULL)";
$ret=mysqli_query($con,$sql);
echo "New student added. You can close this window now.";
exit();
}
?>
<form action="<?php $_PHP_SELF ?>" method="POST">
<p>Your ID:</p> <input type="text" name="id">
<p>Password: </p><input type="password" name="pass">
<p>Name:</p> <input type="text" name="name"><br><br>
<input type="submit" value="Submit Form">
</form>
<p align='right'><i> Instead of 'logging out', you could just close the window.</i></p></body>
</html>