Results 1 to 6 of 6

Thread: Form Data to MySQL Database help

  1. #1
    Join Date
    Mar 2007
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Form Data to MySQL Database help

    first off I made a form in which data can be inputted into my database. For some reason, when I submit it, the data is put in as well as a completely blank insert. Why does that happen?

    Also I want to put images into the database and have images (not links) show up in the php pages. What is the best way to do this?
    Last edited by thetestingsite; 05-14-2007 at 03:00 PM.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Please use a more descriptive title for a thread.

    For the first question, we would need more information such as code or a link to your page.

    For both questions, you should be able to find information in older threads. I know the second question has been answered several times.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Mar 2007
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    PHP Code:
    <?php

        
    include 'session.inc.php';
        include 
    'config.inc.php';
        include 
    'db.inc.php';


        
    $link db_connect();

            
    $date $_POST['date'];
            
    $venue $_POST['venue'];
            
    $location $_POST['location'];
            
    $information $_POST['information'];

            
            
    $query "INSERT INTO showdates VALUES ('$date','$venue','$location','$information')";
                
    db_query($query$link);
                
    db_close(null$link);

        
    $link db_connect();

        
    db_close($result$link);

    ?>
    And the form action:
    PHP Code:
    <form action="<?=$_SERVER['PHP_SELF']?>
    Sorry about the title I can't change it.

  4. #4
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    XXXXX
    Quote Originally Posted by djr33
    For both questions, you should be able to find information in older threads. I know the second question has been answered several times.
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  5. #5
    Join Date
    Mar 2007
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I don't know how to look about my first question though. I was not getting anything in my search..

  6. #6
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    as a side note, you shouldn't trust what a user inputs into a field. I dont know if you just took it out for testing purposes, but you should be sanitizing the data before doing anything else with it.

    research trim() and htmlspecialchars() functions at the very least.


    and your first question is that its inserting 2 rows into the database? I am presently learning MySQL myself, however your last few lines seem suspect? you close the connection, open it, then close it again? and also, you do not have any reference in there to the $result variable?



    // edit: Image Inserts
    http://www.dynamicdrive.com/forums/s...ad.php?t=13327

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
  •