ramu_rp2005 Posted March 13, 2006 Share Posted March 13, 2006 i've sent a value from one page to another,as<a href="browsedirectory.php?typeid=<? echo $id ?>" target=main><font size=2 face="Tahoma"><? echo $name ?></font></a>Now,how to obtain and use the value of typeid in browsedirectory.php .if i use echo typeid; in browsedirectory.php it shows nothing is their.so how do i obtain this value. Link to comment https://forums.phpfreaks.com/topic/4819-urgent-help-needed-for-passing-values-from-one-page-to-another/ Share on other sites More sharing options...
Hooker Posted March 13, 2006 Share Posted March 13, 2006 First off try [code]<a href="browsedirectory.php?typeid=<? echo"$id"; ?>" target=main><font size=2 face="Tahoma"><? echo"$name"; ?></font></a>[/code]then in browsedirectory.php:[code]echo $_GET['typeid'];[/code]that should do it Link to comment https://forums.phpfreaks.com/topic/4819-urgent-help-needed-for-passing-values-from-one-page-to-another/#findComment-16942 Share on other sites More sharing options...
kenrbnsn Posted March 13, 2006 Share Posted March 13, 2006 You wrote:[code]<?php<a href="browsedirectory.php?typeid=<? echo $id ?>" target=main><font size=2 face="Tahoma"><? echo $name ?></font></a>?>[/code]Where is the variable $id getting set? If you put the line[code]<?php echo $id . "<br />"; ?>[/code]just befor the above statement, what gets displayed on your browser?BTW[code]<?php echo $id ?>[/code] is exactly the same as [code]<?php echo "$id"; ?>[/code]Ken Link to comment https://forums.phpfreaks.com/topic/4819-urgent-help-needed-for-passing-values-from-one-page-to-another/#findComment-17005 Share on other sites More sharing options...
psyion Posted March 13, 2006 Share Posted March 13, 2006 okey i'm also learning here... i just learn php for like about 2 weeks now... still learning thou.i hope the codes help ramki.The code that i give are partially made from dreamweaver using "record insertion form wizard" and modified just to send variable but not an sql. I found this way of passing variable while i was stuck with a page where i need to pass names and other variables only.But i need some explenation on some part that i really don't know what does the code mean."code discription passing a variable name id from pageOne.php to pageTwo.php."pageOne.php[code]<?php$editFormAction = $_SERVER['PHP_SELF'];if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);}if ((isset($_POST["hiddenField"])) && ($_POST["hiddenField"] == "form1")) {$id = $_POST['id']; $insertGoTo = "pageTwo.php?id=$id"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo));}?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>pageOne</title></head><body><form id="form1" name="form1" method="post" action="<?php echo $editFormAction; ?>"> <input name="hiddenField" type="hidden" value="form1" /> Input id <input name="id" type="text" id="id" /> <input type="submit" name="Submit" value="Submit" /></form></body></html>[/code]pageTwo.php[code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>pageTwo</title></head><body>id given is = <?php echo $_GET['id']; ?></body></html>[/code][b]so what does this part of the code mean and what is happening here?[/b][code]<?php$editFormAction = $_SERVER['PHP_SELF'];if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);}if ((isset($_POST["hiddenField"])) && ($_POST["hiddenField"] == "form1")) {$id = $_POST['id']; $insertGoTo = "pageTwo.php?id=$id"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo));}?>[/code]And can you guys here teach me the easyway of doing this so i don't need to copy here and cut there just to pass a variable. i got the feeling that the code written have gone a really long way just to pass a variable. thank you. Link to comment https://forums.phpfreaks.com/topic/4819-urgent-help-needed-for-passing-values-from-one-page-to-another/#findComment-17129 Share on other sites More sharing options...
psyion Posted March 13, 2006 Share Posted March 13, 2006 sorry it was a double post. Link to comment https://forums.phpfreaks.com/topic/4819-urgent-help-needed-for-passing-values-from-one-page-to-another/#findComment-17131 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.