index.html file



<form id="form" method="post" action="formdata.php" enctype="text/plain" autocomplete="on" target="_blank">

                 <!-- onsubmit="return confirm('Your request have been submitted. Thank You.')"  onsubmit="this.submit(); this.reset(); return false;">-->        
                <fieldset>
                <legend>Get a FREE Quote</legend>
                      <label for="flname">First and Last name:</label><input type="text" name="flname" autofocus placeholder="Please type your first and last name." size="40" required /><br>
                     <!-- <label for="lname">Last name: </label><input type="text" name="lname" autofocus placeholder="Please type your last name." size="40" required><br>-->
                      <label for="email">E-mail: </label><input type="email" name="email" autocomplete="off" autofocus placeholder="Please type your e-mail." size="40" required /><br>
                      <label for="tel">Telephone: </label><input type="text" name="tel" autofocus placeholder="Please enter your phone number." size="40" required /><br>
                      Describe Request:<textarea name="DescRequest" autofocus placeholder="Please describe your request." maxlength="500" required>

Dani AI

Generated

Short diagnosis: an "Undefined index" notice means PHP tried to read a key from $_POST that did not exist. In 's form the most likely causes are the form using enctype="text/plain" (PHP will not populate $_POST for that content type), relying on a non-existent named submit control, and possible name/case mismatches between the HTML name attributes and the keys accessed in PHP.

Recommended fixes: remove the explicit enctype so the browser uses the default application/x-www-form-urlencoded (only use multipart/form-data for file uploads). Use a real submit control with a name if code checks isset($_POST['submit']), or better check the request method with $_SERVER['REQUEST_METHOD'] === 'POST'. Make sure HTML name attributes exactly match the keys used in PHP (array keys are case-sensitive). Always validate/sanitize server-side and avoid directly accessing $_POST keys without a safe fallback.

Example corrected form (minimal):

<form method="post" action="formdata.php">
  <input type="text" name="flname" required>
  <input type="email" name="email" required>
  <input type="tel" name="tel" required>
  <textarea name="DescRequest" required></textarea>
  <button type="submit" name="submit">Send</button>
</form>

Safe PHP access and quick debug:

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  var_dump($_POST); // inspect what arrived
  $flname = trim($_POST['flname'] ?? '');
  $email  = filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);
  $desc   = trim($_POST['DescRequest'] ?? '');
  // then validate/sanitize before use
}

Extra notes: use the browser Network tab to confirm the Content-Type and request body. If text/plain is intentionally required, read php://input and parse manually. Remove repeated autofocus attributes and never rely only on client-side required — server-side checks prevent undefined index notices and security issues.

undefined names submit, flname, email, tel, descrequest and so forth

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.