Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>Group 22!</title>
- <meta name="description" content="Oblig 3 DATS2410 - Overview of grades">
- <meta name="author" content="David Solheim & Haakon Lien">
- <style type="text/css">
- table, th, td {
- border: 2px solid black;
- }
- table {
- border-collapse: collapse;
- }
- td {
- text-align: center;
- }
- a {color:inherit;text-decoration:none;}
- footer {position:fixed;bottom:0;}
- </style>
- </head>
- <body>
- <?php
- if(isset($_POST['delete'])) {
- $s_nr=$_POST['snr'];
- $server = "10.1.1.212";
- $username = "maxscale";
- $password = "maxscalepass";
- $conn = new mysqli($server, $username, $password);
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql="USE studentinfosys";
- $conn->query($sql);
- $sql="DELETE FROM students WHERE studentid = \"$s_nr\"";
- $conn->query($sql);
- $conn->close();
- }
- if (isset($_POST['addNew'])) {
- $s_nr=$_POST['snr'];
- $fname=$_POST['fname'];
- $lname=$_POST['lname'];
- $mail=$_POST['email'];
- $program=$_POST['program'];
- $year=$_POST['year'];
- $server = "10.1.1.212";
- $username = "maxscale";
- $password = "maxscalepass";
- $conn = new mysqli($server, $username, $password);
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql="USE studentinfosys";
- $conn->query($sql);
- $sql="INSERT INTO students (studentid, firstname, lastname, email, studyprogram, startyear) VALUES (\"$s_nr\",\"$fname\",\"$lname\",\"$mail\",\"$program\",\"$year\")";
- $conn->query($sql);
- $conn->close();
- }
- ?>
- <h1>Welcome to group 22's student management application!</h1>
- <form method="post">
- <h3>Add new student</h3>
- <tr>
- <td><input type="text" name="snr" placeholder="Student number"</td>
- <td><input type="text" name="fname" placeholder="First name"</td>
- <td><input type="text" name="lname" placeholder="Last name"</td>
- <td><input type="text" name="email" placeholder="Email address"</td>
- <td><input type="text" name="program" placeholder="Study program"</td>
- <td><input type="text" name="year" placeholder="Start year"</td>
- <td><input type="submit" name="addNew" value="Add"</td>
- </tr>
- </form>
- <div>
- <table style="width:80%;margin-top:10px;margin-bottom:10px;">
- <thead>
- <tr>
- <th>Student number</th>
- <th>First name</th>
- <th>Last name</th>
- <th>Email</th>
- <th>Study program</th>
- <th>Started</th>
- <th>Actions</th>
- <th></th>
- </tr>
- </thead>
- <tbody>
- <?php
- $conn = new mysqli('10.1.1.212', 'maxscale', 'maxscalepass');
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql="USE studentinfosys";
- $conn->query($sql);
- $sql="SELECT * FROM students";
- $result=$conn->query($sql);
- while($row = $result->fetch_assoc()) {
- ?>
- <tr>
- <td><?php echo $row["studentid"]?></td>
- <td><?php echo $row["firstname"]?></td>
- <td><?php echo $row["lastname"]?></td>
- <td><?php echo $row["email"]?></td>
- <td><?php echo $row["studyprogram"]?></td>
- <td><?php echo $row["startyear"]?></td>
- <td>
- <a href="./courses.php?id=<?php echo $row["studentid"]?>"><button type="submit">View Courses</button></a>
- <form action="edit.php" method="get">
- <input type="hidden" name="snr" value="<?php echo $row["studentid"]?>" />
- <input type="submit" name="edit" value="Edit" />
- </form>
- <form method="post">
- <input type="hidden" name="snr" value="<?php echo $row["studentid"]?>" />
- <input type="submit" name="delete" value="Delete" />
- </form>
- </td>
- </tr>
- <?php
- }
- $conn->close();
- ?>
- </tbody>
- </table>
- </div>
- <footer>
- <p> You are served by this server IP:
- <?php
- $localIP = getHostByName(getHostName());
- echo "$localIP";
- ?>
- </p>
- <p>
- You are served by this server:
- <?php
- $n = getHostName();
- echo "$n";
- ?>
- </p>
- <p>
- Public IP: 128.39.121.59:8022
- </p>
- <p>
- Database IP:
- <?php
- $conn = new mysqli('10.1.1.212','maxscale','maxscalepass');
- printf($conn->host_info);
- $conn->close();
- ?>
- </p>
- </footer>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement