Jump to content

Archived

This topic is now archived and is closed to further replies.

LostNights

Receiving Variables in a form

Recommended Posts

Im am sending a variable from a link to another page so that I can update a row in the database based on that variable. Im just a little confused exactly how the line of code goes.



This is from the page sending the variable sku
[code]
<?php do { ?>
        <div class="employee2">
        <p>
            <?php echo "Record # " . $row_Recordset1['sku']; ?> |
            <?php echo $row_Recordset1['firstname']; ?>
            <?php echo $row_Recordset1['lastname']; ?> |
            <?php echo $row_Recordset1['title']; ?> |
            <?php echo $row_Recordset1['department']; ?> |
            <?php echo $row_Recordset1['phone']; ?> |
            <?php echo $row_Recordset1['office']; ?> |
            <a href="infoupdate.php?id=<?php echo $row_Recordset1['sku']; ?>">Edit Info</a>
        </p>
        </div>
    
    <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
[/code]

This is the page receiving the variable, do I have to type something special? cause I cant echo out $sku

I want this $sku variable to also retrieve the info for that # and put it into form fields that can be used to update.

[code]
$query = "INSERT INTO directory SET firstname='$_POST[firstname]', lastname='$_POST[lastname]',title='$_POST[title]',department='$_POST[department]',office='$_POST[office]',phone='$_POST[phone]' WHERE sku='".$sku."'";
[/code]

Share this post


Link to post
Share on other sites
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--][code]<a href="infoupdate.php?id=<?php echo $row_Recordset1['sku']; ?>"> [/code][/quote]

if register globals are on you'll access that value through $id since thats what you called it.
Otherwise it'll be $_REQUEST['id'];

Share this post


Link to post
Share on other sites
[!--quoteo(post=372789:date=May 9 2006, 08:45 PM:name=KrisNz)--][div class=\'quotetop\']QUOTE(KrisNz @ May 9 2006, 08:45 PM) [snapback]372789[/snapback][/div][div class=\'quotemain\'][!--quotec--]
if register globals are on you'll access that value through $id since thats what you called it.
Otherwise it'll be $_REQUEST['id'];[/quote]

Play safe. Code assuming register_globals is OFF which will work whether it's ON or OFF.

[code]$sku = $_GET['id']; // retrieve URL passed value[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.