Hi All, I am a beginner to html and need you help to get this into our school search index. I have a form which opens a url, but i want to open this url in the background or hidden, and get certain parameter from the new url and open another url that is visible to the user. My form looks like this .. <FORM style="MARGIN: 0px" name=finder onsubmit="document.write(document.thisform.query.value);return false;" action="http://www.xxxxxxxx.com/pfinder" method=get> <input id=query size=25 value="Enter your product number" name=query> <input type="submit" value="Submit »"> </FORM> the above from open a url with the search the user inputs and results in a url that looks like http://www.xxxxxxx.com/product?product=yyyyyy i need your help to extract parrametrs product=yyyyyy" from the new url that opens and insert it to another url http://www.xxxxx.com/useCategory?product=yyyyyy Please let me know how this can be achieved easily... I promise that ill get back to helping others after i have learnt html completely..
This cannot be done using HTML alone. HTML is not a programming language. You can use PHP for this purpose. The URL valiable can be extracted using this <?php echo $_REQUEST['yyyyyy']; ?> Code (markup): or <?php echo $_GET['yyyyyy']; ?> Code (markup): Please mention more specifically about your requirement (of extracting the variable and how it'll be used), so that folks here can help you with the exact piece of code.
Hi, let change the full thing, if some one could help me with php. In the HTML page i have form, in to which the user in puts a value (query) and hits submit. <FORM style="MARGIN: 0px" name=finder onsubmit="document.write(document.thisform.query.value);return false;" action="pfinder.php" method=get> <input id=query size=25 value="Enter your product number" name=query> <input type="submit" value="Submit »"> </FORM> this value should be added to a url (http://www.xxxxxxxx.com/pfinder) and run in the background (http://www.xxxxxxxx.com/pfinder?query=xxxx), which would give me a variable (product) in the new url (http://www.xxxxxxx.com/product?product=yyyyyy "i dont want this page to open"). php should capture this new url and extract the variable (product=) and add it to the new url (http://www.xxxxx.com/useCategory?product=yyyyyy) and run this which the user should see.. please can some one help me in the complete php code that would be needed.... Pleaseeeee..
Please relate xxxx and yyyyyy in the above problem. Are they same? If not, then how to determine yyyyyy, when xxxx is provided. I can give you the solution.
Hi, "Query=xxxx", xxxx here is a user input, then this query is run the URL changes from http://www.site.com/pfinder?query=xxxx to a new vaue http://www.site.com/product?product=yyyyyy, "yyyyyy" is a code for the xxxx value that the user inputs. They are not the same. (xxxxxx is a 6 digit alphanumeric value, and yyyyyyy is a 7 digit numeric code.)
Hi Got a little, this is the actual code in php <?php $path = "http://h10025.www1.hp.com/ewfrf/wc/pfinder"; $name = "query"; $value = "$_GET[query]"; $url = $path . "?$name=$value"; print($url); ?> instead of print i want this url to run in the background, write down the new url that looks like "http://h10025.www1.hp.com/ewfrf/wc/product?product=1234567" now get the new $value1 $path1 = "http://h10025.www1.hp.com/ewfrf/wc/useCategory"; $name1 = "product"; $value1 = "$_GET[product]"; $url1 = $path1 . "?$name1=$value1"; print($url1); (open this url in browser for user to see).. Can this be done..
You can do the same thing with much less code by using this in your form action script. $value = "$_GET[query]"; header("Location: http://h10025.www1.hp.com/ewfrf/wc/useCategory?product=$value"); PHP:
Thanks to all, on the net, i was able to get the redirect working, with some help.. code below <?php $mob = str_replace("+", "_", $_SERVER['QUERY_STRING']); $url = "http://h10025.www1.hp.com/ewfrf/wc/pfinder?" . "$mob"; /** * get_redirect_url() * Gets the address that the provided URL redirects to, * or FALSE if there's no redirect. * * @param string $url * @return string */ function get_redirect_url($url){ $redirect_url = null; $url_parts = @parse_url($url); if (!$url_parts) return false; if (!isset($url_parts['host'])) return false; //can't process relative URLs if (!isset($url_parts['path'])) $url_parts['path'] = '/'; $sock = fsockopen($url_parts['host'], (isset($url_parts['port']) ? (int)$url_parts['port'] : 80), $errno, $errstr, 30); if (!$sock) return false; $request = "HEAD " . $url_parts['path'] . (isset($url_parts['query']) ? '?'.$url_parts['query'] : '') . " HTTP/1.1\r\n"; $request .= 'Host: ' . $url_parts['host'] . "\r\n"; $request .= "Connection: Close\r\n\r\n"; fwrite($sock, $request); $response = ''; while(!feof($sock)) $response .= fread($sock, 8192); fclose($sock); //echo $response; if (preg_match('/^Location: (.+?)$/m', $response, $matches)){ return trim($matches[1]); } else { return false; } } /** * get_all_redirects() * Follows and collects all redirects, in order, for the given URL. * * @param string $url * @return array */ function get_all_redirects($url){ $redirects = array($url); while ($newurl = get_redirect_url($url)){ if (in_array($newurl, $redirects)){ break; } $redirects[] = $newurl; $url = $newurl; } return $redirects; } /** * get_final_url() * Gets the address that the URL ultimately leads to. * Returns $url itself if it isn't a redirect. * * @param string $url * @return string */ function get_final_url($url){ $redirects = get_all_redirects($url); if (count($redirects)>0){ return array_pop($redirects); } else { return $url; } } $fin = get_final_url($url); $mov = parse_url($fin, PHP_URL_QUERY); sleep(5); header("Location: http://h10025.www1.hp.com/ewfrf/wc/useCategory?$mov"); ?> But now i have a problem, the server i was to put this on does not support PHP. (server side) I know this is not the right forum, but can any one help me to get this done in javascript (client side)