jquery - HTML form Textarea. Sending data to MySQL using PHP. Notice: Undefined index -


i trying send data form data base, keep on having same error @ textarea part.

i not sure whether has data type in mysql, tried setting text, medium, text, long text , etc.

the connection successful. other information input successful except of textarea thingy.

using xampp.

the reason why put form action link because want find file.

below codes

code html;

<!doctype html> <html lang="en">      <head>         <meta charset="utf-8"/>         <title> competition organizer </title>         <link rel="stylesheet" href="main.css">     </head>      <body>         <ul>              <li><a href="">log out</a></li>             <li><a>notification</a></li>             <li><a href="report.html">generate report</a></li>             <li><a href="admin.html">home</a></li>             <li style="float:left;color:white;">competition management</li>         </ul>         <form action="http://localhost/gcsweb/add.php" method="post">             <div>                 <br>                 <br>                 <br>                  <label><b>competition name</b></label>                 <input type="text" placeholder="enter competiton name" name="compname" required>                  <label><b>competition mentor</b></label>                 <input type="text" placeholder="enter competiton mentor name" name="compmenname" required>                  <label><b>competiton description</b></label>                 <textarea rows="20" cols="50" name="compdescription" form="compform" placeholder="enter description here..." required></textarea>                  <br>                  <input type="submit" value="submit" name="submit">             </div>         </form>      </body>  </html> 

code php;

connection sql;

<?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->setattribute(pdo::attr_errmode, pdo::errmode_exception);     echo "connected successfully";      } catch(pdoexception $e)     {     echo "connection failed: " . $e->getmessage();     } ?> 

send data;

<?php  include "connection.php";  $compname = $_post['compname']; $compmenname = $_post['compmenname']; $compdescription = $_post['compdescription']; //this doesnt work   if(isset($_post["submit"])){      try{     $sql = "insert competition(name,host,description) values ('".$compname."','".$compmenname."','".$compdescription."')";      if ($connection->query($sql)){         echo"<script type= 'text/javascript'>alert('new record inserted successfully');</script>";     }else{         echo "<script type= 'text/javascript'>alert('data not inserted.');</script>";     }      $connection = null;     }      catch(pdoexception $e){         echo $sql . "<br>" . $e->getmessage();     } } ?> 

thank you

you're defining non-existent form include textarea in - form="compform"

remove , textarea included when submit form.

to add, put in form attribute textarea if textarea located outside form tags

example:

<form id="my_form">   <!-- other form elements here --> </form>  <textarea name="my_txt" form="my_form"></textarea> 

Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -