Jump to content


Photo

Receiving Variables in a form


  • Please log in to reply
2 replies to this topic

#1 LostNights

LostNights
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 09 May 2006 - 09:14 PM

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
<?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)); ?>

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.

$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."'";


#2 KrisNz

KrisNz
  • Members
  • PipPipPip
  • Advanced Member
  • 271 posts
  • LocationAuckland, New Zealand

Posted 10 May 2006 - 12:45 AM

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
<a href="infoupdate.php?id=<?php echo $row_Recordset1['sku']; ?>">
[/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'];

#3 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 10 May 2006 - 12:53 AM

[!--quoteo(post=372789:date=May 9 2006, 08:45 PM:name=KrisNz)--][div class=\'quotetop\']QUOTE(KrisNz @ May 9 2006, 08:45 PM) View Post[/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.

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


Legend has it that reading the manual never killed anyone.
My site




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users