If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2003
    Toronto, Canada
    Member #
    Hi guys,

    I can't describe how frustrated this has made me.. and it's the littlest thing but I can't go any further without it working..

    I have a simple form with a textfield and a submit button

    The main goal is to send the value of the textfield to the database when you click Submit..

    Problem is that when I click submit it updates the database but it inserts a blank instead of the value I typed in the textfield..
    When I do my INSERT command where I use the textfield variable I'm also using a CURDATE() to insert a date into the database which actually works and the dates shows up in the database.

    Given that I can now narrow it down to the fact that php just won't recognize the value of my textfield... BUT.. when I use a post method for my form to see the URL values passed the value for my textfield (which PHP doesn't recognize) is in fact displayed in the URL..

    here is the full code
    <form action="<?=$PHP_SELF?>" method="get">
    <p>Type your name here:<br />
    <input type = "text" name = "initial"><br />
    <input type="submit" name="submitjoke" value="SUBMIT" /></p>
    <?php // Default page display
    // Connect to the database server
    $dbcnx = @mysql_connect("localhost", "root", "");
    if (!$dbcnx) { echo( "<p>Unable to connect to the " . "database server at this time.</p>" ); exit();

    }else {
    echo("Connected to Dabase Server");

    // Select the employee database
    if (! @mysql_select_db("employee") ) {
    echo( "<p>Unable to locate the employee " . "database at this time.</p>" );
    else {
    echo("Connected to database employee");

    this part right now does not execute since I'm once again trying to use a variable from my form. If I remove the first condition where I check for SUBMIT it processes the sql INSERT statement and inserts the date but of course not the Name
    if ($submitjoke == "SUBMIT") {
    $sql = "INSERT INTO hrdata SET Name = '$initial', Hired = CURDATE()";
    if (@mysql_query($sql)) {
    echo("<p>Your name has been added.</p>"); }
    else {
    echo("<p>Error adding name: " . mysql_error() . "</p>");

    echo("<p> Here are all the names in our database: </p>");
    $result = @mysql_query("SELECT Name, Hired FROM hrdata");
    if (!$result) { echo("<p>Error performing query: " . mysql_error() . "</p>"); exit();
    } // Display the text of each joke in a paragraph
    while ( $row = mysql_fetch_array($result) ) { echo("<p>" . $row["Name"] . " " . $row["Hired"] ."</p>"); }

    does anybody know what's going on here?

    Thank you kindly in advance


  3. #2
    I found these threads that look to be similar to yours. Do any of them help?

    If they don't a human will be along soon anyway to help you out more.

  4. #3
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Maryland, US
    Member #
    21 times
    Make sure you have register_globals on, or use the $_GET/$_POST arrays instead.
    filburt1, Web Design founder
    Site of the Month contest: submit your site or vote for the winner!

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
All times are GMT -6. The time now is 12:05 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2020 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: