Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- OPERAHAN NYO NALANG.
- ------------------------------------------------------------------------------------------------
- index.php
- ------------------------------------------------------------------------------------------------
- <?php
- include "db/conn.php";
- $fname = $lname = $mname = $course = $attendance = $exercise = $quiz = $exam = $finalGrade ="";
- if(isset($_POST['register'])){
- $fname = $_POST['fname'];
- $lname = $_POST['lname'];
- $mname = $_POST['mname'];
- $course = $_POST['course'];
- $attendance = $_POST['attendance'];
- $exercise = $_POST['exercise'];
- $quiz = $_POST['quiz'];
- $exam = $_POST['exam'];
- $fattendance = (($attendance/90)*.10)*100;
- $fexercise = (($exercise/100)*.25)*100;
- $fquiz = (($quiz/100)*.25)*100;
- $fexam = (($exam/200)*.40)*100;
- $finalGrade = ($fattendance+$fexercise+$fquiz+$fexam);
- $sql = mysqli_query($conn, "INSERT INTO tbl_info (firstName,lastName,middleName,course,attendance,exercise,quiz,exam,finalGrade)"."VALUES
- ('$fname','$lname','$mname','$course','$attendance','$exercise','$quiz','$exam','$finalGrade')");
- }
- ?>
- <html>
- <header>
- <title></title>
- </header>
- <body>
- <div class="body-content">
- <div class="module">
- <h1>Create an account</h1>
- <form class="form" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">
- <label>First Name</label><input type="text" name="fname" value="<?php echo $fname ?>" />
- <label>Last Name</label><input type="text" name="lname" value="<?php echo $lname ?>" />
- <label>Middle Name</label><input type="text" name="mname" value="<?php echo $mname ?>" />
- <label>Course</label><input type="text" name="course" value="<?php echo $course ?>" />
- <label>Attendance</label><input type="text" name="attendance" value="<?php echo $attendance ?>" />
- <label>Exercise</label><input type="text" name="exercise" value="<?php echo $exercise ?>" />
- <label>Quiz</label><input type="text" name="quiz" value="<?php echo $quiz ?>" />
- <label>Exam</label><input type="text" name="exam"value="<?php echo $exam ?>" />
- <label>Final Grade</label><input type="text" name="fg" disabled value="<?php echo $finalGrade ?>" />
- <input type="submit" value="Register" name="register" class="btn btn-block btn-primary" />
- <button type="button" class="btn btn-block btn-primary"><a href="view.php">View Students </a></button>
- </form>
- </div>
- </div>
- </body>
- </html>
- ------------------------------------------------------------------------------------------------
- view.php // VIEW RECORDS
- ------------------------------------------------------------------------------------------------
- <?php
- include "db/conn.php";
- ?>
- <html>
- <head>
- </head>
- <body>
- <div class="container">
- <table class="table table-striped mt-5 text-center">
- <thead class="thead-dark">
- <tr>
- <th>StudentID</th>
- <th>First Name</th>
- <th>Last Name</th>
- <th>Middle Name</th>
- <th>Course</th>
- <th>Attendance</th>
- <th>Exercise</th>
- <th>Quiz</th>
- <th>Exam</th>
- <th>Final Grade</th>
- </tr>
- </thead>
- <?php
- $sql = mysqli_query($conn, "Select * from tbl_info");
- while($row = mysqli_fetch_array($sql)){
- echo "<tr>";
- echo "<td>". $row['studentID']."</td>";
- echo "<td>". $row['firstName']."</td>";
- echo "<td>". $row['lastName']."</td>";
- echo "<td>". $row['middleName']."</td>";
- echo "<td>". $row['course']."</td>";
- echo "<td>". $row['attendance']."</td>";
- echo "<td>". $row['exercise']."</td>";
- echo "<td>". $row['quiz']."</td>";
- echo "<td>". $row['exam']."</td>";
- echo "<td>". $row['finalGrade']."</td>";
- echo "</tr>";
- }
- ?>
- </table>
- </div>
- </body>
- </html>
- ------------------------------------------------------------------------------------------------
- conn.php //CONNECTION
- ------------------------------------------------------------------------------------------------
- <?php
- $server = "localhost";
- $username = "root";
- $password = "";
- $db = "dbmidtermlab";
- // Create connection
- $conn = mysqli_connect($server, $username, $password, $db);
- // Check connection
- if (!$conn) {
- die("Connection failed: " . mysqli_connect_error());
- }else{
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement