SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: Input>database

  1. #1
    SitePoint Guru
    Join Date
    Jun 2001
    Location
    Australia
    Posts
    676
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Input>database

    Hi all,

    Im working on a small database that requires these imputs: Website Title, Catagory and URL.

    This is the code I have so far, but im not sure how to input the "catagory" into the database.

    PHP Code:
    <center> <form action="insert.php" method ="POST">
    <
    table width="400">
    <
    tr>
     <!-- 
    Website Title -->
    <
    td width="150"><b>Website Title:</b></td>
    <
    td>
    <
    input type "text" name "title" maxlength="100">
    </
    td>
    </
    tr>

     <!-- 
    Catagory section ((name "catagory")) -->
     <
    tr>
    <
    td valign="top" width="150"><b>Discription: </b></td>
    <
    td>
    <
    select name="Select">
    <
    option value="catagory#1">catagory#1
    <option value="catagory#2">catagory#2
    <option value="catagory#3">catagory#3
    </select>
    </
    td></tr><tr>

     <!-- 
    URL -->
    <
    td width="150"><b>URL: </b></td>
    <
    td valign="middle">
    <
    input type "text" name "url" maxlength="100" value="http://">
    </
    td>
    </
    tr>
    <
    tr>
    <
    td width="150"></td>
    <
    td>
    <
    input type "submit" value "Submit TGP">
    </
    td>
    </
    tr>
    </
    table>
    </
    form></center
    Any help would be great. Thanks.

  2. #2
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So where's your php?
    thats nothing but html.
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  3. #3
    SitePoint Guru
    Join Date
    Jun 2001
    Location
    Australia
    Posts
    676
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, it is HTML but it users the name = "title"
    to place into the database via the insert.php file.

    Here is the insert.php file which that form uses.
    PHP Code:
    <?php

    include("config.php");

    mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database");

    mysql_select_db ($DBname);

    // Insert stuff

    mysql_query ("INSERT INTO websites (Title,Date,Catagory,URL) values ('$title', (now()),'$catagory','$url')");

    // Confirmation of insert

    echo "Your website with title <b> \"" $title "\" </b> \"" $Catagory "\" has been succesfully inserted in the database.<p>";
    echo 
    "<a href=\"index.php\"><font size=2>Back</font></a>";

    ?>

  4. #4
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    just insert $Select into the database.
    and is this even working yet?
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  5. #5
    SitePoint Guru
    Join Date
    Jun 2001
    Location
    Australia
    Posts
    676
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not sure I understand what you mean by $Select

    You can find the working demo here

  6. #6
    SitePoint Guru
    Join Date
    Jun 2001
    Location
    Australia
    Posts
    676
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Im such a pinhead.
    I found the problem. I has "select" instead of "Catagory". hmm. Thanks Defender1

    was
    PHP Code:
     <!-- Catagory section ((name "catagory")) -->
     <
    tr>
    <
    td valign="top" width="150"><b>Discription: </b></td>
    <
    td>
    <
    select name="select">
    <
    option value="catagory#1">catagory#1
    <option value="catagory#2">catagory#2
    <option value="catagory#3">catagory#3
    </select>
    </
    td></tr><tr
    now is
    PHP Code:
     <!-- Catagory section ((name "catagory")) -->
     <
    tr>
    <
    td valign="top" width="150"><b>Discription: </b></td>
    <
    td>
    <
    select name="catagory">
    <
    option value="catagory#1">catagory#1
    <option value="catagory#2">catagory#2
    <option value="catagory#3">catagory#3
    </select>
    </
    td></tr><tr


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
  •