function checkInputs()
{
$fname = $_POST["fname"];
$lname = $_POST['lname'];
$email = $_POST['email'];
...
}
<form method = 'POST' action = 'index.php'>
First Name:<input type = 'text' name = 'fname'>
Last Name:<input type = 'text'name = 'lname'>
Email:<input type = 'text' name = 'email'>
</form>
The function isn’t called until a button is clicked.
Regardless I’ve tried putting the php tag after the page loads and regardless it still produces the error ‘Undefined index : … at Line
You need to check if the value exists first before trying to use it
If someone left the fname field blank and submitted your form then it would not be set in the $_POST var