SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2010
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    can't post data into DB throught textarea

    hi everybody I am trying to do a form with name a text area with two buttons Go and preview,the problem is when I am trying to put data into data base through textarea doesn't work when I cheak phpmyadmin I don't see any thing in the area field.so please help
    thanks in advance
    PHP Code:
    <html>
    <head>
    <body>

       <?php
       error_reporting
    (E_ALL E_NOTICE);
       if(isset(
    $_POST['submit']))
       {
     
        echo 
    stripslashes($_POST['area']);
      
        }
        if(!
    $connect=mysql_connect('localhost','root','')){
        exit(
    'unable to connect to the data base');}
        
       
    // select database
        
    if (!mysql_select_db('topic')){
        exit (
    'unable to locate database');}
        
      
        echo 
    $name=isset($_POST["name"]) ? $_POST['name'] : "";
       
        
       
    $insert="INSERT INTO omar SET
       name='" 
    mysql_real_escape_string($name) . "' ,area='" .     mysql_real_escape_string($area) . "'";

        if(!
    $a=mysql_query($insert)) {
        exit( 
    'error query'.mysql_error());
       }

    //fetching data from database

    $db_search mysql_query("SELECT name FROM omar");

    if (@
    mysql_num_rows($db_search) > 0) {

    while(
    $data mysql_fetch_array($db_search)) 
    { Print 
    "<b>Name:</b> ".$data['name'] . "<br/>" 
     Print 
    "<b>Area:</b> ".$data['area'] . "<br/>" ;
    }
    }



    ?>

    <form action="duty1.php"  method="post">
    name:<input type="text" name="name"/><br />
    <textarea name="area " cols="60" rows="10">
    </textarea><br/>




    <input type="submit" value="GO" />




    </form>
    </body>
    </head>
    </html>

  2. #2
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,606
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    There is a space in the name attribute for the textarea. That might be causing a problem.
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2010
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you ,I tried but it didn't work .

  4. #4
    SitePoint Enthusiast
    Join Date
    Apr 2011
    Location
    north-east england
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    there is no mysql sever try to take out line 25

  5. #5
    SitePoint Enthusiast
    Join Date
    Apr 2011
    Location
    north-east england
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    forget that check it for syntex

  6. #6
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    157 Post(s)
    Tagged
    3 Thread(s)
    you are not defining $area anywhere. You do it for name but not for area.
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  7. #7
    SitePoint Enthusiast
    Join Date
    Feb 2010
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <html>
    <head>
    <body>

       <?php
       error_reporting
    (E_ALL E_NOTICE);
       if(isset(
    $_POST['submit']))
       {
     
        echo 
    stripslashes($_POST['area']);
      
        }
        if(!
    $connect=mysql_connect('localhost','root','')){
        exit(
    'unable to connect to the data base');}
        
       
    // select database
        
    if (!mysql_select_db('topic')){
        exit (
    'unable to locate database');}
        
      
        echo 
    $name=isset($_POST["name"]) ? $_POST['name'] : "";
       
        
       
    $insert="INSERT INTO omar SET
       name='" 
    mysql_real_escape_string($name) . "' ,area='" .     mysql_real_escape_string($area) . "'";

        if(!
    $a=mysql_query($insert)) {
        exit( 
    'error query'.mysql_error());
       }

    //fetching data from database

    $db_search mysql_query("SELECT name FROM omar");

    if (@
    mysql_num_rows($db_search) > 0) {

    while(
    $data mysql_fetch_array($db_search)) 
    { Print 
    "<b>Name:</b> ".$data['name'] . "<br/>" 
     Print 
    "<b>Area:</b> ".$data['area'] . "<br/>" ;
    }
    }



    ?>

    <form action="duty1.php"  method="post">
    name:<input type="text" name="name"/><br />
    <textarea name="area " cols="60" rows="10"><?php echo $area=isset($_POST["area"]) ? $_POST['area'] : "";?>
    </textarea><br/>




    <input type="submit" value="GO" />




    </form>
    </body>
    </head>
    </html>
    [/QUOTE]


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •