+ Reply to Thread
Results 1 to 7 of 7

Thread: Update Form not submitting

  1. #1
    ChiBuki is offline x10Hosting Member ChiBuki is an unknown quantity at this point
    Join Date
    Sep 2008
    Posts
    11

    Update Form not submitting

    Hi,

    For my character data table, I'm making an update form in a page for users to update. It appears when I submit the info, it didn't change anything in my mysql database. I went over this several times but couldn't find the cause and it's probably something minor...

    This is the php before body:
    PHP Code:
    <?php
    include("connect.php");

    if(isset(
    $_POST["action"]))
    {
        
    $sFeaturedCharacter $_POST["featuredcharacter"];
        
    $sRank $_POST["rank"];
        
    $sAverage $_POST["average"];
        
    $sPointsEarned $_POST["pointsearned"];
        
    $sTotalVotes $_POST["totalvotes"];
        
    $sFivePoints $_POST["fivepoints"];
        
    $sFourPoints $_POST["fourpoints"];
        
    $sThreePoints $_POST["threepoints"];
        
    $sTwoPoints $_POST["twopoints"];
        
    $sOnePoints $_POST["onepoints"];
        
    $sDateUpdated $_POST["dateupdated"];
        
    $iID $_POST['which'];
        
    $query "UPDATE CharacterData SET
                FeaturedCharacter ='"
    .$sFeaturedCharacter."',
                Rank ='"
    .$sRank."',
                Average ='"
    .$sAverage."',
                PointsEarned ='"
    .$sPointsEarned."',
                TotalVotes ='"
    .$sTotalVotes."',
                FivePoints ='"
    .$sFivePoints."',
                FourPoints ='"
    .$sFourPoints."'
                ThreePoints ='"
    .$sThreePoints."'
                TwoPoints ='"
    .$sTwoPoints."'
                OnePoints ='"
    .$sOnePoints."'
                DateUpdated ='"
    .$sDateUpdated."'
                WHERE ID = "
    .$iID;
                
        
    //Run query
        
    $result mysql_query($query);
        if(!
    result)
        {
            echo 
    $query;
            die(
    "Could not query the databse:<br />"mysql_error());
        }
    }

    if(!isset(
    $iID))
    {
        
    $iID $_GET["id"];
    }
    $query "SELECT * FROM CharacterData WHERE ID = $iID";

    //Run query
    $result mysql_query($query);
    if(!
    $result)
    {
        die(
    "Could not query the database:<br />"mysql_error());
    }
    $row mysql_fetch_assoc($result);
    ?>
    And the page itself:
    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Update A Character</title>
    <script type="text/javascript" src="ton.js"></script>
    <link href="ton.css" rel="stylesheet" type="text/css" />
    </head>
    
    <body>
    <div id="container">
        <h1>Update A Character</h1>
        <h3>Updating data for <?php echo $row["FeaturedCharacter"];?></h3>
        <form id="editcharacter" name="editcharacter" method="post" action="edittest.php">
            <label for="rank">Character Rank:</label>
            <select name="rank" id="rank">
            <option value="A+" <?php if ($sRank == "A+") { echo("selected='selected'"); }; ?>>A+</option>
            <option value="A" <?php if ($sRank == "A") { echo("selected='selected'"); }; ?>>A</option>
            <option value="A-" <?php if ($sRank == "A-") { echo("selected='selected'"); }; ?>>A-</option>
            <option value="B-" <?php if ($sRank == "B+") { echo("selected='selected'"); }; ?>>B+</option>
            <option value="B" <?php if ($sRank == "B") { echo("selected='selected'"); }; ?>>B</option>
            <option value="B-" <?php if ($sRank == "B-") { echo("selected='selected'"); }; ?>>B-</option>
            <option value="C+" <?php if ($sRank == "C+") { echo("selected='selected'"); }; ?>>C+</option>
            <option value="C" <?php if ($sRank == "C") { echo("selected='selected'"); }; ?>>C</option>
            <option value="C-" <?php if ($sRank == "C-") { echo("selected='selected'"); }; ?>>C-</option>
            <option value="D+" <?php if ($sRank == "D+") { echo("selected='selected'"); }; ?>>D+</option>
            <option value="D" <?php if ($sRank == "D") { echo("selected='selected'"); }; ?>>D</option>
            <option value="F" <?php if ($sRank == "F") { echo("selected='selected'"); }; ?>>F</option>
            </select>
            <br />
            <label for="average">Average:</label>
            <input type="text" name="average" id="average"  maxlength="4" value="<?php echo $row["Average"];?>" />
            <br />
            <label for="pointsearned">Total Points Earned:</label>
            <input type="text" name="pointsearned" id="pointsearned"  maxlength="4" value="<?php echo $row["PointsEarned"];?>" />
            <br />
            <label for="totalvotes">Total Votes:</label> 
            <input type="text" name="totalvotes" id="totalvotes" maxlength="4" value="<?php echo $row["TotalVotes"];?>" />
            <br />
            <label for="fivepoints">5 pts:</label>
            <input type="text" name="fivepoints" id="fivepoints"  maxlength="3" value="<?php echo $row["FivePoints"];?>" />
            <br />
            <label for="fourpoints">4 pts:</label>
            <input type="text" name="fourpoints" id="fourpoints"  maxlength="3" value="<?php echo $row["FourPoints"];?>" />
            <br />
            <label for="threepoints">3 pts:</label>
            <input type="text" name="threepoints" id="threepoints"  maxlength="3" value="<?php echo $row["ThreePoints"];?>" />
            <br />
            <label for="twopoints">2 pts:</label>
            <input type="text" name="twopoints" id="twopoints"  maxlength="3" value="<?php echo $row["TwoPoints"];?>" />
            <br />
            <label for="onepoints">1 pts:</label>
            <input type="text" name="onepoints" id="onepoints"  maxlength="3" value="<?php echo $row["OnePoints"];?>" />
            <br /><br />
            <input type="hidden" name="dateupdated" id="dateupdated" value="<?php echo date('Y-m-d');?>" />
            <input type="hidden" name="which" value="<?php echo $row["ID"];?>" />
            <input type="hidden" name="action" id="action" value="edit" />
            <input type="submit" name="Submit" value="Update this Character" />
            <?php
            if(isset($_POST["action"]))
            {
            ?>
            <p style="color:red">Changes Saved.</p>
            <?php } ?>
        </form>
        <p><a href="http://forums.x10hosting.com/programming-help/characterlist.php">Back to Main Page</a></p>
    </div>
    </body>
    </html>
    <?php
    mysql_close($connection);
    ?>
    Additionally, where it says "Character Rank:" I think something's wrong with the code. It should display the character's rank by default, but instead it always display the first option in the dropdown menu. In addition to my not-submitting form, can someone please point out the right way to echo dropdown menu using PHP?

    Thanks.
    Last edited by ChiBuki; 11-02-2008 at 12:22 AM.

  2. #2
    xPlozion's Avatar
    xPlozion is offline x10 Elder xPlozion is an unknown quantity at this point
    Join Date
    Mar 2008
    Location
    Delaware, USA
    Posts
    872

    Re: Update Form not submitting

    last line of your query
    Code:
    WHERE ID = ".$iID;
    try
    Code:
    WHERE ID = '".$iID."'";
    Last edited by xPlozion; 11-02-2008 at 01:58 AM.

  3. #3
    ChiBuki is offline x10Hosting Member ChiBuki is an unknown quantity at this point
    Join Date
    Sep 2008
    Posts
    11

    Re: Update Form not submitting

    Still not updating unfortunately.

  4. #4
    xmakina's Avatar
    xmakina is offline x10 Lieutenant xmakina is an unknown quantity at this point
    Join Date
    May 2008
    Location
    England
    Posts
    265

    Re: Update Form not submitting

    Interesting. Add to your error reporting the $query variable. Take that output and run it in the phpMyAdmin SQL area, it'll provide you with a more descriptive error and you can also edit the query faster.
    IF($this->$post.content() == "SEE SIG"){
    w3Schools and Google
    }

  5. #5
    mephis's Avatar
    mephis is offline x10Hosting Member mephis is an unknown quantity at this point
    Join Date
    Aug 2008
    Location
    London, UK
    Posts
    39

    Re: Update Form not submitting

    It might also be a good idea to dump your $_POST vars, since you say:
    Quote Originally Posted by ChiBuki View Post
    Additionally, where it says "Character Rank:" I think something's wrong with the code. It should display the character's rank by default, but instead it always display the first option in the dropdown menu. In addition to my not-submitting form (...)
    You might be generating some malformed HTML there which is screwing up your _POST, and in turn screwing up the query

  6. #6
    ChiBuki is offline x10Hosting Member ChiBuki is an unknown quantity at this point
    Join Date
    Sep 2008
    Posts
    11

    Re: Update Form not submitting

    Okay it didn't seem to report back an error with error_reporting(E_ALL). Now I decided to throw the dropdown menu altogether for debugging test and use simple input text for the rank, yet the form is still not submitting. :happysad:

    HTML Code:
    <label for="rank">Character Rank:</label> 
            <input type="text" name="rank" id="rank" maxlength="3" value="<?php echo $row["Rank"];?>" />
    When I click the submit button, the value changes back to teh database value.

    _______________________
    Update
    I found the syntax error. I missed commas at the php and now the form submits.

    PHP Code:
    FourPoints ='".$sFourPoints."'
                
    ThreePoints ='".$sThreePoints."'
                
    TwoPoints ='".$sTwoPoints."'
                
    OnePoints ='".$sOnePoints."'
                
    DateUpdated ='".$sDateUpdated."' 
    However, new problem arose. I tried using the dropdown menu again, and whenever I click inside the <select></select> tag, Dreamweaver crashed every single time. That scared me but it seems to be OK with regular text form.
    Last edited by ChiBuki; 11-02-2008 at 01:57 PM. Reason: Automerged Doublepost

  7. #7
    freecrm's Avatar
    freecrm is offline x10 Elder freecrm is an unknown quantity at this point
    Join Date
    May 2008
    Location
    UK
    Posts
    629

    Re: Update Form not submitting

    Quote Originally Posted by ChiBuki View Post
    Dreamweaver crashed every single time.
    Don't you just love DW!!!

    Its fine when you only use the pre-set functions but as soon as you put in anything different, DW stops working for an "unspecified" reason.

    This might make you think you've screwed your code up, or worse... Dreamweaver - but its OK - Its just DW playing games with your mind!!!

    I have multiple crash errors now with my site although the code is fine and works great..

    I might be going back to notepad!:nuts:

+ Reply to Thread

Similar Threads

  1. Problems with Form submitting (HTML/PHP)
    By apulaiset in forum Programming Help
    Replies: 9
    Last Post: 08-27-2008, 07:01 AM
  2. Ways around submitting a form using a hyperlink?
    By slpixe in forum Programming Help
    Replies: 6
    Last Post: 04-02-2008, 12:41 PM
  3. A simple Visual Basic Login Form
    By Zenax in forum Tutorials
    Replies: 0
    Last Post: 03-13-2007, 08:59 AM
  4. New PSP UPGADE
    By IamShipon1988 in forum Gamer's Lounge
    Replies: 4
    Last Post: 09-04-2005, 08:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers