yandoo Posted March 28, 2008 Share Posted March 28, 2008 Hi there, I have a form that updates a record in a database...At the moment on Update the user is directed to another page.... Is there a way i can parse the ID value that was just updated to the other page (like a hyperlink, e.g. ?recordID=<?php echo $row_record['ID']; ?>)......Because i need to parse the ID to the other page! Is this possible??? If so how please?? Thank You Link to comment https://forums.phpfreaks.com/topic/98351-parse-form-variable/ Share on other sites More sharing options...
DyslexicDog Posted March 28, 2008 Share Posted March 28, 2008 Can you show some code of what you have in place currently? Link to comment https://forums.phpfreaks.com/topic/98351-parse-form-variable/#findComment-503293 Share on other sites More sharing options...
discomatt Posted March 28, 2008 Share Posted March 28, 2008 Yes, if you use that method, on the 'other page' use $_GET['recordID'] Be sure to sanitize and verify all user input Link to comment https://forums.phpfreaks.com/topic/98351-parse-form-variable/#findComment-503294 Share on other sites More sharing options...
cooldude832 Posted March 28, 2008 Share Posted March 28, 2008 a session would be better probably <?php session_start(); $id = $_POST['ID']; #Update query $_SESSION['ID'] = $id' die(header("location: page2.php")); ?> page2.php <?php session_start(); $id = $_SESSION['ID']; ?> Link to comment https://forums.phpfreaks.com/topic/98351-parse-form-variable/#findComment-503295 Share on other sites More sharing options...
yandoo Posted March 28, 2008 Author Share Posted March 28, 2008 Hello Heres the code: if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE animal SET BreedID=%s, Age=%s, Sex=%s, Image=%s WHERE AnimalID=%s", GetSQLValueString($_POST['select'], "text"), GetSQLValueString($_POST['age'], "int"), GetSQLValueString($_POST['sex'], "text"), GetSQLValueString($_POST['image'], "text"), GetSQLValueString($_POST['AnimalID'], "int")); mysql_select_db($database_woodside, $woodside); $Result1 = mysql_query($updateSQL, $woodside) or die(mysql_error()); $updateGoTo = "view_animal_details.php";[code] [/code] Link to comment https://forums.phpfreaks.com/topic/98351-parse-form-variable/#findComment-503296 Share on other sites More sharing options...
discomatt Posted March 28, 2008 Share Posted March 28, 2008 Why start a session to pass variables originally defined by the user? Sessions are a great way to track events between pages, but for something as simple as an ID that you might not even want to carry on to the next page (browses away to another page on the domain perhaps) why use the overhead? If you already have a session started, i don't see why you couldn't... but you'd have to verify that id was for that page specifically. If the user browses to another page that uses the same session variable it could result in undesirable effects. Link to comment https://forums.phpfreaks.com/topic/98351-parse-form-variable/#findComment-503300 Share on other sites More sharing options...
yandoo Posted March 28, 2008 Author Share Posted March 28, 2008 Hi, 0 On the second page i need to know the ID updated in the form.....Is there a away do it it without Session??? Thanks Link to comment https://forums.phpfreaks.com/topic/98351-parse-form-variable/#findComment-503306 Share on other sites More sharing options...
discomatt Posted March 28, 2008 Share Posted March 28, 2008 Read my initial post (3rd down) Link to comment https://forums.phpfreaks.com/topic/98351-parse-form-variable/#findComment-503308 Share on other sites More sharing options...
yandoo Posted March 28, 2008 Author Share Posted March 28, 2008 Hi, oh yes i see it that brill thanks, all fine for 2nd page but how would i parse it from the first after update??? thinkig in terms of hyperlinks recordID=<?php echo $row_animal['AnimalID']; ?> Im bit confussed how to put add it $updateGoTo = "view_animal_details.php"; If thats even the way to do it Thanks Link to comment https://forums.phpfreaks.com/topic/98351-parse-form-variable/#findComment-503315 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.