

<!DOCTYPE HTML>  
<html>
<head>
     <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://getbootstrap.com/docs/5.3/assets/css/docs.css" rel="stylesheet">
    <title>PARENTS : SIGNUP</title>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
  
  <style>
.error {color: #FF0000;}
body {
  background-color: aqua;
}
</style>
  
  </head>


<body class="p-3 m-0 border-0 bd-example m-0 border-0">
 
 <?php
    //to1 is the variable name for the school
    $to1Err = "";
    
    $to1 = "";
 
 
    //other variables

    $counter = 0 ;

if ($_SERVER["REQUEST_METHOD"] == "POST") {
  
 
  //codes for transfer to1
  if (empty($_POST["to1"])) {
    $to1Err = "Town/City name is required";
  } else {
    $to1 = test_input($_POST["to1"]);
    $counter++;
  }
  
    
    
    }
 
 
 function test_input($data) {
  $data = trim($data);
  $data = stripslashes($data);
  $data = htmlspecialchars($data);
  return $data;
}
function wording($data) {
  $data = strtolower($data);
  $data = ucwords($data);
  return $data;
}
 
 
 ?>
    <u><center><h2>Please select school name.</h2></center></u>
<p><span class="error">* required field</span></p>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">  


     <label for="exampleDataList" class="form-label" style="color:red;">* Select school. </label>
<input class="form-control" list="towns" id="exampleDataList" name= "to1" placeholder="1. Type and select school name." required >
<datalist id="towns">
  <option value="">
  
  
  <?php
$servername = "localhost";
$username = "commemay_sono";
$password = "Masiu@5$5$5$";
$dbname = "commemay_csc";

        // Create connection
        $conn = new mysqli($servername, $username, $password, $dbname);
        // Check connection
        if ($conn->connect_error) {
              die("Connection failed: " . $conn->connect_error);
        }

        $sql = "SELECT school FROM schools";
        $result = $conn->query($sql);

        if ($result->num_rows > 0) {
         // output data of each row
         while($row = $result->fetch_assoc()) {
       
       
       $school = $row["school"];
      
       echo '<option value="'.$school.'">';
       
       
         }
            } 
        $conn->close();
?> 
  
    </datalist>
    
      <br />   
    <div class="d-grid gap-2 col-6 mx-auto">
  <button type="submit" class="btn btn-primary" type="button">View Concerns</button>
  
</div>
 
  
    </form>
    
    
    
    
    
    
</body>
</html>  

   