Php post with textarea

Discussion in 'PHP' started by samindika, May 22, 2008.

  1. #1
    I created simple database which store data using a simple from
    But I added textarea. I cannot see the textarea data in database and all other fields are ok

    Form Page
    <form id="form1" name="form1" method="post" action="add2.php">
      <table width="864" border="1" cellspacing="0" cellpadding="00">
        <tr>
          <td width="97" height="44">Title</td>
          <td width="761"><input name="title" type="text" id="title" size="100" /></td>
        </tr>
        <tr>
          <td height="39">Summary</td>
          <td><input name="sum" type="text" id="sum" size="100" /></td>
        </tr>
        <tr>
          <td height="184">Text</td>
          <td><textarea rows="8" name="text1" cols="68"></textarea></td>
        </tr>
        <tr>
          <td height="41">Author</td>
          <td><input name="by" type="text" id="by" size="100" /></td>
        </tr>
        <tr>
          <td height="24">&nbsp;</td>
          <td><label>
            <input type="submit" name="Submit" value="Submit" />
          </label></td>
        </tr>
      </table>
    </form>
    
    HTML:

    Database page
    <?
    $username="*******";
    $password="*********";
    $database="*********";
     
    $title=$_POST['title'];
    $sum=$_POST['sum'];
    $text=$_POST['text1'];
    $by=$_POST['by'];
    
    
    
    mysql_connect(localhost,$username,$password);
    @mysql_select_db($database) or die( "Unable to select database");
    
    $query = "INSERT INTO data VALUES ('','$title','$sum','$text','$by')";
    mysql_query($query);
    
    mysql_close();
    ?>
    PHP:

     
    samindika, May 22, 2008 IP
  2. saurabhj

    saurabhj Banned

    Messages:
    3,459
    Likes Received:
    61
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Your code is fine. I think there may be some variable are overwritten. Please post the whole page code. Both are the different pages or same?
     
    saurabhj, May 22, 2008 IP
  3. samindika

    samindika Active Member

    Messages:
    336
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #3
    different pages..
    this is the full code...

     
    samindika, May 22, 2008 IP
  4. emily

    emily Well-Known Member

    Messages:
    1,252
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    175
    #4
    Change:
    <td><textarea rows="8" name="text1" cols="68"></textarea></td>
    PHP:
    to:
    <td><textarea rows="8" id="text1" cols="68"></textarea></td>
    PHP:
     
    emily, May 22, 2008 IP
  5. o0DarkEvil0o

    o0DarkEvil0o Peon

    Messages:
    11
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Your Code is works, check whole code
     
    o0DarkEvil0o, May 22, 2008 IP