LostNights Posted May 9, 2006 Share Posted May 9, 2006 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 $skuI 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 https://forums.phpfreaks.com/topic/9428-receiving-variables-in-a-form/ Share on other sites More sharing options...
KrisNz Posted May 10, 2006 Share Posted May 10, 2006 [!--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 https://forums.phpfreaks.com/topic/9428-receiving-variables-in-a-form/#findComment-34788 Share on other sites More sharing options...
AndyB Posted May 10, 2006 Share Posted May 10, 2006 [!--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 https://forums.phpfreaks.com/topic/9428-receiving-variables-in-a-form/#findComment-34790 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.