SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Guru themightystephen's Avatar
    Join Date
    Mar 2005
    Location
    England
    Posts
    608
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ID not being passed through $_POST

    Hi,

    I cannot understand why the ID of the product is not being passed from this page to another page that processes the form.

    Here is the form.

    PHP Code:
    echo '<tr><form action="update_availability_DB.php" method="post">';

    // There are lots of other input checkboxes in between.

    // Need hidden field to pass heelys model id
    ?>
        <input type="hidden" name="heelysmodel" value"<?php echo $heelys_shoe_id?>" />
    <?php
        
    echo '</tr><tr><td colspan="14"><input type="submit" value="Update Availability" name="stockavailability" /></td></tr></form></table></p>';
    Here is the page that it is passed to. The problem is I know it is not being passed because I tried echoing it out on the processing page.

    PHP Code:
    <?php error_reporting(E_ALL); ?>
    <!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=iso-8859-1" />
    <?php $header 'Update Availability of Heelys Shoes - Immediate Stock and Pre-orders'?>
    <title><?php echo $header?></title>
    <link rel="stylesheet" href="../adminstyle.css" />
    </head>
    <body>
    </body>
    </html>
    <?php
    require_once($_SERVER['DOCUMENT_ROOT'].'/Flywalk PHP/Admin CMS/Includes/header2.inc.php'); // Get header
    require_once($_SERVER['DOCUMENT_ROOT'].'/Flywalk PHP/Admin CMS/Includes/connectselectdb2.inc.php'); // Connect to MySQL and select database
    $field = array('size_ukk12','size_ukk13','size_uk1','size_uk2','size_uk3','size_uk4','size_uk5','size_uk6','size_uk7','size_uk8','size_uk9','size_uk10','size_uk11',);

    if(isset(
    $_POST['stockavailability']) && isset($_POST['heelysmodel'])) {
        
    // Assign $heelys_shoe_id to the number of model passed
        
    $heelys_shoe_id $_POST['heelysmodel']; // The heelysmodel variable isn't getting passed on for some reason
        
    echo $heelys_shoe_id;
        foreach (
    $_POST['hidden'] as $key => $size) { 
            if(isset(
    $_POST['unavailablepreorders'][$size])) { 
                echo 
    'Pre order checked - '.$_POST['unavailablepreorders'][$size].'<br />';
                
    $makeunavailable 'Y';
            } else { 
                   echo 
    'Not checked<br />';
                
    $makeunavailable 'N';
            }
            
    $idexists "SELECT*FROM heelys_unavailable_preorders WHERE heelys_shoe_id='$heelys_shoe_id'";
            if(
    mysql_num_rows(mysql_query($idexists)) != 1) {
            
    // Insert a record into database if that id doesn't exist
            
    echo $field[$key];
            
    $sql "INSERT INTO heelys_unavailable_preorders SET heelys_shoe_id = '$heelys_shoe_id',".$field[$key]." = ".$makeunavailable;
            
    mysql_query($sql);
            }
            else {
            
    // Update the record with that id if it does exist
            
    $sql "UPDATE heelys_unavailable_preorders SET ".$field[$key]." = ".$makeunavailable." WHERE heelys_shoe_id = '$heelys_shoe_id'";
            
    mysql_query(sql);
            }
            
        } 


    }
        
    // Close connection to DB
        
    mysql_close($dbcnx);

    // Show where to go next
    echo 'See the <a href="view_models_DB.php">Heelys Models list</a>.';
    ?>
    Thanks
    Get your heelys now at flywalk.co.uk - But what are heelys?
    Heelys are simply shoes with wheels in the heels!

    Flywalk.co.uk - The UK Heelys Retailer

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    On this line in your first block of code:

    PHP Code:
    <input type="hidden" name="heelysmodel" value"<?php echo $heelys_shoe_id?>" />
    You're missing the equals (=) sign after the word "value".

  3. #3
    SitePoint Guru themightystephen's Avatar
    Join Date
    Mar 2005
    Location
    England
    Posts
    608
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    lol. I'll try that!
    Get your heelys now at flywalk.co.uk - But what are heelys?
    Heelys are simply shoes with wheels in the heels!

    Flywalk.co.uk - The UK Heelys Retailer

  4. #4
    SitePoint Guru themightystephen's Avatar
    Join Date
    Mar 2005
    Location
    England
    Posts
    608
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmm...didn't seem to solve the problem...
    Get your heelys now at flywalk.co.uk - But what are heelys?
    Heelys are simply shoes with wheels in the heels!

    Flywalk.co.uk - The UK Heelys Retailer

  5. #5
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    View source of the page in your browser and see if the HTML is correct and the ID is in the hidden field before posting.

    Also, you cannot use the name of your submit button as a test that the form was posted. Some browsers don't send this, and I don't believe Internet Explorer ever sends it if you press enter to submit a form instead of clicking the button.

  6. #6
    SitePoint Guru themightystephen's Avatar
    Join Date
    Mar 2005
    Location
    England
    Posts
    608
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes it is...I guess the problem must lie in the other processing page or maybe somewhere else in the form.
    Get your heelys now at flywalk.co.uk - But what are heelys?
    Heelys are simply shoes with wheels in the heels!

    Flywalk.co.uk - The UK Heelys Retailer

  7. #7
    SitePoint Guru themightystephen's Avatar
    Join Date
    Mar 2005
    Location
    England
    Posts
    608
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, it's now suddenly working.... very odd.

    Thanks anyway for spotting the mistake I made.
    Get your heelys now at flywalk.co.uk - But what are heelys?
    Heelys are simply shoes with wheels in the heels!

    Flywalk.co.uk - The UK Heelys Retailer


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
  •