I have created php submit button using form action with the intention of just storing a username and school name to be stored in a database using xampp by clicking okay button. I have set the database table to have flds for ID as primary key and AI, username and school set to varchar with max length of 50. The code i have used shown does $con to the DB but only the ID is being send to the DB?? (what have i missed or need to do so that the data inputted can be stored like the ID)?.
<?php
require 'config.php';
$username = " "; //$username
$school = " ";//what school they attend
if(isset($_POST['register_button'])){
$_SESSION['reg_username'] = $username; //Stores first name into session variable
$_SESSION['reg_school'] = $school; //Stores first name into session variable
$query = mysqli_query($con, "INSERT INTO users VALUES ('', '$username', '$school')");
}
?>
<html>
<head>
<title> School </title>
</head>
<body>
<h1> Welcome! </h1>
<form action="index.php" method="POST">
<input type="text" name="reg_username" placeholder="Name" value="<?php
if(isset($_SESSION['reg_username'])) {
echo $_SESSION['reg_username'];
}
?>" required>
<br>
<input type="text" name="reg_school" placeholder="School" value="<?php
if(isset($_SESSION['reg_school'])) {
echo $_SESSION['reg_school'];
}
?>" required>
<br>
<input type="submit" name="register_button" value="Okay">
</body>
</html>