Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <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;
- }
- footer {position:fixed;bottom:0;}
- </style>
- </head>
- <body>
- <a href="./index.php">Go back to the overview of students</a>
- <h1>
- <?php
- if (isset($_GET['snr'])) {
- $s_nr=$_GET['snr'];
- echo "Edit entry for " . $s_nr;
- } else {
- echo "Missing student identity. Please try again.";
- }
- ?></h1>
- <?php
- if (isset($_GET['editentry'])) {
- #get values
- $s_nr=$_GET['snr'];
- $fname=$_GET['fname'];
- $lname=$_GET['lname'];
- $mail=$_GET['email'];
- $program=$_GET['program'];
- $year=$_GET['year'];
- #connect
- $server = "10.1.1.212";
- $username = "maxscale";
- $password = "maxscalepass";
- $conn = mysqli_connect($server, $username, $password);
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql="USE studentinfosys";
- $conn->query($sql);
- $sql="UPDATE students SET studentid=\"$s_nr\", firstname=\"$fname\", lastname=\"$lname\", email=\"$mail\", studyprogram=\"$program\", startyear=\"$year\" WHERE studentid=\"$s_nr\"";
- if($conn->query($sql) === TRUE) {
- header("Location: ./index.php");
- exit;
- } else {
- echo "<p>Error editing entry: " . $conn->error . "</p>";
- }
- $conn->close();
- }
- ?>
- <form method="get">
- <table>
- <tr>
- <th>Student number</th>
- <th>First name</th>
- <th>Last name</th>
- <th>Email</th>
- <th>Study program</th>
- <th>Start year</th>
- <th>Action</th>
- </tr>
- <tbody>
- <?php
- $server = "10.1.1.212";
- $username = "maxscale";
- $password = "maxscalepass";
- $dbname = "studentinfosys";
- $s_nr = "";
- if(isset($_GET['snr'])) {
- $s_nr = $_GET['snr'];
- }
- $conn = mysqli_connect($server, $username, $password);
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql="USE studentinfosys";
- $conn->query($sql);
- $result=$conn->query("SELECT * FROM students WHERE studentid=\"$s_nr\"");
- while($row = $result->fetch_assoc()) {
- ?>
- <tr>
- <td><input type="text" name="snr" value="<?php echo $row["studentid"]?>" /></td>
- <td><input type="text" name="fname" value="<?php echo $row["firstname"]?>" /></td>
- <td><input type="text" name="lname" value="<?php echo $row["lastname"]?>" /></td>
- <td><input type="text" name="email" value="<?php echo $row["email"]?>" /></td>
- <td><input type="text" name="program" value="<?php echo $row["studyprogram"]?>" /></td>
- <td><input type="text" name="year" value="<?php echo $row["startyear"]?>" /></td>
- <td><input type="submit" name="editentry" value="Edit entry" /></td>
- </tr>
- <?php
- }
- $conn->close();
- ?>
- </tbody>
- </table>
- </form>
- <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