I’m having trouble running this php code with my database in phpmyadmin in cpanel

  html, mysql, php, phpmyadmin, sql

I’m having trouble running this code in phpmyadmin. It is not storing anything in the RESERVATIONS table. I’ve spent hours trying to figure this out. I tried putting the queries in manually in phpmyadmin and that was successful. However, running it in the php file is another story. The table is called RESERVATIONS and it has columns:

image of table RESERVATIONS columns

    require 'dbconfig/config.php';

<!DOCTYPE html>
<title>Registration Page</title>
<link rel="stylesheet" href="css/style.css">
<body style="background-color:#bdc3c7">

    <div id="main-wrapper">
            <h2>Registration Form</h2>
        <form class="GuestForm">
    <label for="fname">First Name:</label>
    <input type="text" name="fname" id="fname" required>
    <label for="lname">Last Name:</label>
    <input type="text" name="lname" id="lname" required>
    <label for="phoneNum">GuestPhone:</label>
    <input type="text" name="phoneNum" id="phoneNum" required>
    <label for="emailaddr">GuestEmail:</label>
    <input type="text" name="emailaddr" id="emailaddr" required>
    <label for="dateNtime">DateTime:</label>
    <input type="text" name="dateNtime" id="dateNtime" required>
    <label for="partySize">Party Size:</label>
    <input type="number" name="partySize" id="partySize" min="0" max="10" required>
        <input name="submit_btn" type="submit" id="signup_btn" value="Create Reservation"/><br>
                echo '<script type="text/javascript"> alert("Submit button clicked") </script>';
                $fname = $_POST['fname'];
                $lname = $_POST['lname'];
                $phoneNum = $_POST['phoneNum'];
                $emailaddr = $_POST['emailaddr'];
                $dateNtime = $_POST['dateNtime'];
                $partySize = $_POST['partySize'];
                    $query = "SELECT dateNtime from RESERVATIONS WHERE dateNtime = '$dateNtime'";
                    $query_run = mysqli_query($con,$query);
                    //$length = mysql_field_len(username, 0);
                        // There is already a reservation for that particular date and time
                        echo '<script type="text/javascript"> alert("There is already a reservation for that particular date and time") </script>';
                        $result = mysqli_query($conn, 'SELECT SUM(table_size) AS value_sum FROM DININGTABLES WHERE occupied = 0'); 
                        $row = mysqli_fetch_assoc($result); 
                        $sum = $row['value_sum'];
                        echo $sum;
                        $query = "INSERT into RESERVATIONS(reservation_id, registered_user, username, fname,lname,phoneNum, emailaddr, dateNtime, partySize) values('NULL', 'NULL', 'NULL','$fname','$lname', '$phoneNum', '$emailaddr', '$dateNtime', '$partySize')";
                        $query_run = mysqli_query($con,$query);
                            echo '<script type="text/javascript"> alert("Reservation created but not really") </script>';
                            echo '<script type="text/javascript"> alert("Error!") </script>';

This isn’t meant to be a public thing, just for a school project. I’m not concerned about security since it won’t be deployed

Source: Ask PHP