title: How do I fix this undefined array key?
body: <p>This is the error currently show. Below The first code I save as details.php and the second on as details.html</p>
  <p>Warning: Undefined array key &quot;first_name&quot; in C:\xampp\htdocs\children_math\detail2.php on line 12</p>
  <p>Warning: Undefined array key &quot;last_name&quot; in C:\xampp\htdocs\children_math\detail2.php on line 13</p>
  <p>Warning: Undefined array key &quot;email&quot; in C:\xampp\htdocs\children_math\detail2.php on line 14</p>
  <p>Warning: Undefined array key &quot;age&quot; in C:\xampp\htdocs\children_math\detail2.php on line 15
  ERROR: Could not able to execute INSERT INTO details (first_name, last_name, email, age) VALUES ('', '', '', ''). Cannot add or update a child row: a foreign key constraint fails (<code>record</code>.<code>details</code>, CONSTRAINT <code>details_ibfk_1</code> FOREIGN KEY (<code>id</code>) REFERENCES <code>users</code> (<code>id</code>))</p>
  <pre><code>/* Attempt MySQL server connection. Assuming you are running MySQL
  server with default setting (user 'root' with no password) */
  $link = mysqli_connect(&quot;localhost&quot;, &quot;root&quot;, &quot;&quot;, &quot;record&quot;);
   
  // Check connection
  if($link === false){
      die(&quot;ERROR: Could not connect. &quot; . mysqli_connect_error());
  }
   
  // Escape user inputs for security
  $first_name = mysqli_real_escape_string($link, $_REQUEST['first_name']);
  $last_name = mysqli_real_escape_string($link, $_REQUEST['last_name']);
  $email = mysqli_real_escape_string($link, $_REQUEST['email']);
  $age = mysqli_real_escape_string($link, $_REQUEST['age']);
   
  // Attempt insert query execution
  $sql = &quot;INSERT INTO details (first_name, last_name, email, age) VALUES ('$first_name', '$last_name', '$email', '$age')&quot;;
  if(mysqli_query($link, $sql)){
      echo &quot;Records added successfully.&quot;;
  } else{
      echo &quot;ERROR: Could not able to execute $sql. &quot; . mysqli_error($link);
  }
   
  // Close connection
  mysqli_close($link);
  ?&gt;
  
  &lt;!DOCTYPE html&gt;
  &lt;html lang=&quot;en&quot;&gt;
  &lt;head&gt;
  &lt;meta charset=&quot;UTF-8&quot;&gt;
  &lt;title&gt;Add Record Form&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form action=&quot;detail2.php&quot; method=&quot;post&quot;&gt;
      &lt;p&gt;
          &lt;label for=&quot;firstName&quot;&gt;First Name:&lt;/label&gt;
          &lt;input type=&quot;text&quot; name=&quot;first_name&quot; id=&quot;firstName&quot;&gt;
      &lt;/p&gt;
      &lt;p&gt;
          &lt;label for=&quot;lastName&quot;&gt;Last Name:&lt;/label&gt;
          &lt;input type=&quot;text&quot; name=&quot;last_name&quot; id=&quot;lastName&quot;&gt;
      &lt;/p&gt;
      &lt;p&gt;
          &lt;label for=&quot;emailAddress&quot;&gt;Email Address:&lt;/label&gt;
          &lt;input type=&quot;text&quot; name=&quot;email&quot; id=&quot;emailAddress&quot;&gt;
      &lt;/p&gt;
      &lt;p&gt;
          &lt;label for=&quot;ages&quot;&gt;Email Address:&lt;/label&gt;
          &lt;input type=&quot;text&quot; name=&quot;age&quot; id=&quot;ages&quot;&gt;
      &lt;/p&gt;
      &lt;input type=&quot;submit&quot; value=&quot;Submit&quot;&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;```
  </code></pre>