PHP代码中没有处理Html搜索栏值

I am trying to make a search bar that goes through the database and return a table. The value from the form is stored but the php code doesn't return any array of information.

Here is the code:

    <?php
    header("Location:http://127.0.0.1:58199/graduateYearPage.html");
    if (isset($_GET['uni_name']) && is_string($_GET['uni_name'])) {
        $uname = $_GET['uni_name'];
    } else {
        $uname = "";
    }

    $con = new mysqli('127.0.0.1', 'root', 'tR60135400', 'db');

    if ($con->connect_errno) {
        echo "We are experiencing problems.";
        exit;
    }

    $sql = "SELECT * FROM students WHERE university = $uname";

    if (!$result = $con->query($sql)) {
        echo "Sorry, the website is experiencing problems.";
        exit;
    }

    if ($result->num_rows === 0) {
        echo "We could not find a match for ID $uname, sorry about that. Please try again.";
        exit;
    } else {
        //OUTPUT A TABLE
        echo "<table> <ul>"
        while($row = $result->fetch_assoc()){
            printf ("<li>%s</li>", $row["firstName"]);
            printf ("<li>%s</li>", $row["lastName"]);
            printf ("<li>%s</li>", $row["university"]);
        }
        echo "</ul> </table>"
    }
    $result->free();
    $con->close();
    exit;
?>

After I get this working this will be a pop up message inside a Bootstrap modal. The table is not working. I also thought that this may be because of the form and how I call the php code.

Here is the html code for the form:

<form method="GET" id="search_bar" style="text-align: center;">
    <div class="input-group">
        <input id="placeholder" type="search" class="form-control" name="uni_name" placeholder=" Enter a university name.">
        <div class="input-group-btn">
            <button class="btn btn-default" type="submit" name="submit">
            <i class="glyphicon glyphicon-search"></i>
            </button>
        </div>
    </div>
</form>

Try this:

index.html or index.php

<form method="GET" id="search_bar" action="search_bar.php" style="text-align: center;">
    <div class="input-group">
        <input id="placeholder" type="search" class="form-control" name="uni_name" placeholder=" Enter a university name.">
        <div class="input-group-btn">
            <button class="btn btn-default" type="submit" name="submit">
            <i class="glyphicon glyphicon-search"></i>
            </button>
        </div>
    </div>
</form>

search_bar.php

<?php
if($_SERVER["REQUEST_METHOD"]="GET"){
    if(isset($_GET["uni_name"])){
         $uname = $_GET['uni_name'];
    }else{
         $uname = "";
    }
}

$con = new mysqli('127.0.0.1', 'root', 'tR60135400', 'db');

if ($con->connect_errno) {
    echo "We are experiencing problems.";
    exit;
}

$sql = "SELECT * FROM students WHERE university = '$uname'";

if (!$result = $con->query($sql)) {
    echo "Sorry, the website is experiencing problems.";
    exit;
}

if ($result->num_rows === 0) {
    echo "We could not find a match for ID $uname, sorry about that. Please try again.";
    exit;
} else {
    //OUTPUT A TABLE
    echo "<table> <ul>"
    while($row = $result->fetch_assoc()){
        printf ("<li>%s</li>", $row["firstName"]);
        printf ("<li>%s</li>", $row["lastName"]);
        printf ("<li>%s</li>", $row["university"]);
    }
    echo "</ul> </table>"
}
$result->free();
$con->close();
exit;
?>

in Bootstrap modal you should change in the href tag of the modal opener this tag "data-target=" or remove it because it means modal view mode whether opens a modal view or redirect to a page. also I notice in your search query a string should be in single quotes

SELECT * FROM students WHERE university = '$uname'