Jump to content

Receiving Variables in a form


LostNights

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]
Link to comment
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'];
Link to comment
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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.