mercredi 1 avril 2015

PHP - Redirect to another page after getting node values from current page

I want to redirect user to another page after getting node values from current page and passing them into the URL's parameter, here is my code:



<?php

$dom = new DOMDocument;
$html = file_get_contents(home_url(). $_SERVER['REQUEST_URI']);
$dom->loadHTML($html);

$addresses = $dom->getElementsByTagName('address');


foreach ($addresses as $key => $address) {
$add[$key] = $address->nodeValue;
}


$fields['address'] = urlencode($add[0]);

$qry = http_build_query($fields);

if(!empty($qry)){
header( 'Location: http://ift.tt/1F3N91f?' . $qry) ;
}

?>


It does redirect successfully, but http_build_query values are empty. Here's an example of redirect: http://ift.tt/1xzUhov , the URL is without the value of $_GET['address'] .


Aucun commentaire:

Enregistrer un commentaire