title: HTML form Textarea. Sending data to MySQL using PHP. Notice: Undefined index
body: <p>I was trying to send data from my Form to My data base, but i keep on having the same error at the Textarea part.</p>
  
  <p>I am not sure whether i has to do with data type in MYSQL, but i tried that also by setting it to text, medium, text, long text and etc.</p>
  
  <p>The connection is successful. All the other information are input successful as well except of The textarea thingy.</p>
  
  <p>Using  XAMPP.</p>
  
  <p>The reason why i put form action as a link is because i want it to find my file.</p>
  
  <p>Below are my codes</p>
  
  <p>Code for HTML;</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  
      &lt;head&gt;
          &lt;meta charset="utf-8"/&gt;
          &lt;title&gt; Competition Organizer &lt;/title&gt;
          &lt;link rel="stylesheet" href="main.css"&gt;
      &lt;/head&gt;
  
      &lt;body&gt;
          &lt;ul&gt; 
              &lt;li&gt;&lt;a href=""&gt;Log Out&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a&gt;Notification&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href="Report.html"&gt;Generate Report&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href="Admin.html"&gt;Home&lt;/a&gt;&lt;/li&gt;
              &lt;li style="float:left;color:white;"&gt;Competition Management&lt;/li&gt;
          &lt;/ul&gt;
          &lt;form action="http://localhost/GCSweb/add.php" method="POST"&gt;
              &lt;div&gt;
                  &lt;br&gt;
                  &lt;br&gt;
                  &lt;br&gt;
  
                  &lt;label&gt;&lt;b&gt;Competition Name&lt;/b&gt;&lt;/label&gt;
                  &lt;input type="text" placeholder="Enter Competiton Name" name="compname" required&gt;
  
                  &lt;label&gt;&lt;b&gt;Competition Mentor&lt;/b&gt;&lt;/label&gt;
                  &lt;input type="text" placeholder="Enter Competiton Mentor Name" name="compmenname" required&gt;
  
                  &lt;label&gt;&lt;b&gt;Competiton Description&lt;/b&gt;&lt;/label&gt;
                  &lt;textarea rows="20" cols="50" name="compdescription" form="CompForm" placeholder="Enter Description Here..." required&gt;&lt;/textarea&gt;
  
                  &lt;br&gt;
  
                  &lt;input type="submit" value="Submit" name="submit"&gt;
              &lt;/div&gt;
          &lt;/form&gt;
  
      &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>Code for PHP;</p>
  
  <p>Connection to SQL;</p>
  
  <pre><code>&lt;?php
  
  $DB_host = "localhost";
  $DB_user = "root";
  $DB_password = "";
  $DB_name = "competition_system";
  
  try{
      $connection=new PDO("mysql:host=$DB_host;dbname=$DB_name",$DB_user.$DB_password);
      $connection-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
      echo "Connected successfully"; 
      }
  catch(PDOException $e)
      {
      echo "Connection failed: " . $e-&gt;getMessage();
      }
  ?&gt;
  </code></pre>
  
  <p>Send data;</p>
  
  <pre><code>&lt;?php
  
  include "connection.php";
  
  $compname = $_POST['compname'];
  $compmenname = $_POST['compmenname'];
  $compdescription = $_POST['compdescription']; //THis doesnt work
  
  
  if(isset($_POST["submit"])){
  
      try{
      $sql = "INSERT INTO competition(Name,Host,Description) VALUES ('".$compname."','".$compmenname."','".$compdescription."')";
  
      if ($connection-&gt;query($sql)){
          echo"&lt;script type= 'text/javascript'&gt;alert('New Record Inserted Successfully');&lt;/script&gt;";
      }else{
          echo "&lt;script type= 'text/javascript'&gt;alert('Data not successfully Inserted.');&lt;/script&gt;";
      }
  
      $connection = null;
      }
  
      catch(PDOException $e){
          echo $sql . "&lt;br&gt;" . $e-&gt;getMessage();
      }
  }
  ?&gt;
  </code></pre>
  
  <p>Thank you</p>