Not signed in (Sign In)

SkillShare - A place to discuss Web Standards and Web Design topics

Categories

Vanilla 1.1.9 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorjustjack
    • CommentTimeNov 3rd 2006
     permalink
    My table is called "hobbies" and my field name in the database is titled "hobbie"

    Can anyone find the error below as to why the selection will not post to mysql? It says that the submission was successful.

    Thanks

    if(isset($_POST['submit']))
    {
    $hobbies = $_POST['hobbie'];
    mysql_connect($host,$user,$password);
    @mysql_select_db($database) or die( "Unable to select database");
    $sqlquery = "INSERT INTO hobbies VALUES(' ".$hobbie." ')";
    $results = mysql_query($sqlquery);
    mysql_close();

    echo "
    <html>
    <head>
    <title> Hobbie List </title>
    </head>
    <body>
    <center>
    <table border='0' width='500'>
    <tr>";

    echo " <td>
    <font face='verdana' size='+0'>
    <center>
    <p>Your submission was successful</p>
    </center>";

    } else {

    echo '
    <form action=" '.$_SERVER['PHP_SELF'].' " method="post" enctype="multipart/form-data"><input type="hidden" name="phpMyAdmin" value="4594f30712f4fabaff6997416810f3f2" /><select name="hobbie">
    <option value="hobbie">Select One</option>
    <option value="hobbie">Running</option>
    <option value="hobbie">Sleeping</option>
    <option value="hobbie">Eating</option>
    </select><input name="submit" type="submit" /></form>
    ';
    }
    ?>
    • CommentAuthordhayes
    • CommentTimeNov 3rd 2006
     permalink
    you're inserting "$hobbie" (misspelled) and not $hobbies as set above.. also, all of your option values are the same, so no matter what you select it's going to show insert the value as "hobbie" and $database isn't defined, but since you're suppressing the error, you're going to be wondering why it's not working even after addressing the aforementioned. it's also vulnerable to attack btw.

    good luck
    • CommentAuthorjustjack
    • CommentTimeNov 3rd 2006
     permalink
    The spelling was intentional. And I solved the problem. As far as "it's also vulnerable to attack btw." would you like to elaborate or offer a solution. I thought this forum was for suppport and solutions.
  1.  permalink
    I suggest to use different forum for that oriented more to php development
    something like http://www.phpfreaks.com/forums/

    This forum related more to CSS/XHTML.

    Best, DS
    • CommentAuthordhayes
    • CommentTimeNov 3rd 2006 edited
     permalink
    jack, sorry for the brevity and the run-on sentence.. i was on my way out. what I was alluding to was that one could write a script that could populate your database with "x" number of records. you could handle the validation in any number of ways: an authentic id (unique for every submission), set a session to prevent repeat posting (ie: 1 post every 5 minutes) and/or validate that the post matches the available options (ie: data integrity).

    good luck
    • CommentAuthorjustjack
    • CommentTimeNov 4th 2006
     permalink
    dhayes,

    As I mentioned in an earlier post, the script was merely a test to ascertain why the data would not go into the database. This is not the form that I am using in the actual database. And I do have an id set for each client, just not in this script, but thanks for the heads up and i will look into data integrity part.

    DS. Didn't know I shouln't be posting here. I use this site for my site development which is CSS and there are a lot of talented people here and since it is "server side coding" I didn't see the problem. I have posted elsewhere on more specific sites, such as the one you mention and no one can ever help. And as it turns out I have solved the problem.

    So thanks everyone. Someone can close this post
Add your comments
    Username Password
  • Format comments as (Help)