0

I have a database in mysql which contains of four tables (Student, Units, Offering and Enrols_in) and i want to create an enrolment page where students can enrol in units which will be offered in each semester. Student names will be entered in the database and they will use their given password and username to log into the system. When they are loged in, they will have to enrol themselves in the units which are offered and the units which they are enroled in will be displayed in their student profile. The part I'm confused is the enrol button and on how many page will I have.

4
Contributors
5
Replies
22
Views
1 Year
Discussion Span
Last Post by Mr.M
0

Well you say you are confused in enrol button but show nothing, also the number of pages depends on how you design your system(site). That means if certain things you will separate to each page or combine some that feet into certain category and group them by categories

0
Okay I have four php page that create using notepad, the pages with the codes are:
1. loginform.php - works fine
2. processlogin.php - need help
<?php

    session_start();

    //retrieve the user name
    $user = $_POST['txtUser']; 
    //retrieve the password
    $pass = $_POST['txtPass'];

    //verify email and password against the database to authenticate the user
        $servername = "localhost";
        $username = "root";
        $password = "";
        $dbname = "enrolment";

    //Create connection
    $conn = mysqli_connect("localhost","root","","enrolment") or die();

    //check the connection
    if(mysqli_connect_error())
    {
        echo "Connection to database failed: " . mysqli_connect_error();
    }
        echo "Connection Successful";

//mysqli_select_dbname('enrolment');
$sql = "SELECT * FROM student WHERE Username = '$user' AND Pass_word = '$pass'";
$result = mysqli_query($conn,$sql);

//Assuming that username and password exist in the database, store the username in a session
if (mysqli_num_rows($result) > 0) {
 $row = mysqli_fetch_array($result);

        $_SESSION["fname"] = $row["FirstName"];
        $_SESSION["lname"] = $row["LastName"];
        $_SESSION["myUser"] = $row["Username"];

    mysqli_close($conn);
    header('location:profile.php');
}
    else    {
            mysqli_close($conn);
            header('location:loginform.html');
            }
?>
3. profile.php - help needed
<?php 
    //start session
    session_start();

    $servername = "localhost";
    $username = "root";
    $password = "";
    $dbname = "enrolment";

    $conn = mysqli_connect("localhost","root","","enrolment"); 
?>
        <a id="logout" href="unit.php">Units to Enrol </a> 
        <h2 style="text-align:center">My Profile</h2>
        <p style="text-align:right"> 

        <?php

            echo "You are logged in as " . $_SESSION["fname"] . " " . $_SESSION["lname"];

        ?>

        <p style="text-align:right"> 
        <a id="logout" href="logout.php">Logout</a> 
        </p>

<?php

        $conn = mysqli_connect("localhost","root","","enrolment");
        $sqlSelect = "SELECT * FROM student";

        $result = mysqli_query($conn,$sqlSelect); //storing the result of the select statement

    if (mysqli_num_rows($result) > 0) { //checking the nuber of rows selected


        echo("<table border='1'>"); //displaying the output data of each row in a tabular format
        echo("<tr><th>Student ID</th><th>Last Name</th><th>First Name</th><th>Year Level</th></tr>");
    while($row = mysqli_fetch_array($result)) {
        echo("<tr>");
        echo("<td>" . $row['StudentId'] . "</td>"); 
        echo("<td>" . $row['LastName'] . "</td>");
        echo("<td>" . $row['FirstName'] . "</td>");
        echo("<td>" . $row['YearLevel'] . "</td>");
        echo("</tr>");
 }
        echo("</table>");
}
    else {
        echo("Record does not exit");
    }

    mysqli_close($conn);

?>
4.unit.php - need help
<html>
<head>
<title>Unit Offerring</title>
</head>
<body>
<h3>List of Units that are offered</h3>
<!--<form method="post" action="profile.php">
    <input type="checkbox" value="checkbox">
</form>-->
</body>
</html>
<?php

Session_start(); //start session

$servername = "localhost";
$username = "root";
$password = "";
$dbname = "enrolment";

$conn= mysqli_connect("localhost","root","","enrolment"); // Create connection

    if (!$conn) {  // Check connection
        die("Connection failed: " . mysqli_connect_error());
}

//specify select statement 

$sqlSelect = "SELECT UnitCode, Uname, Description, ULecturer, Semester, offerNum FROM units, offerings WHERE UnitCode=UCode";

$result = mysqli_query($conn,$sqlSelect); //storing the result of the select statement

    if (mysqli_num_rows($result) > 0) { //checking the nuber of rows selected
        echo("<table border='1'>"); //displaying the output data of each row in a tabular format
        echo("<tr><th>Unit Code</th><th>Name</th><th>Description</th><th>Lecturer</th><th>Semester</th><th>Choose to enrol</th></tr>");
    while($row = mysqli_fetch_array($result)) {
        $offerId = $row['offerNum'];
        echo("<tr>");
        echo("<td>" . $row['UnitCode'] . "</td>");
        echo("<td>" . $row['Uname'] . "</td>");
        echo("<td>" . $row['Description'] . "</td>");
        echo("<td>" . $row['ULecturer'] . "</td>");
        echo("<td>" . $row['Semester'] . "</td>");
        echo("<td><input type='checkbok' name='checkbox[]' value='$offerId'></td>");

        //echo("<td>" . $row['year'] . "</td>");
        echo("</tr>");
 }
        echo("</table>");
}
    else {
        echo("There are no units!");
    }

    mysqli_close($conn); //close connection

    //header('location:profile.php');

    //References: Lectures 8a and 8b
?>
0

I don't see enrol button here. Also state exactly what's giving you problem in which line so that it will be a bit easier for us to help you, as to this question I still don't see the part you say you have a problem with "enrol button" or maybe your question is how to create the enrol button?

Please clarify your question.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.