Page 1 of 1

add a variable from a url into code for posting purposes

Posted: Fri Apr 27, 2012 6:46 pm
by inosent1
after i process a query on a page i redirect back to the originating page, where i place the all important file_id place on the tail end of the url

now, when i arrive back at the originating page instead of 'test.com/page.php' like it was when i first landed on it, now it says:

test.com/page.php?file_id=120

what i want to do is somehow grab that '120' and post it, ie:

$fid = [everything on the right of the = of the url];

tia

Re: add a variable from a url into code for posting purposes

Posted: Fri Apr 27, 2012 7:54 pm
by inosent1

Code: Select all

function curPageURL() {
 $pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];

 } else {
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];

 }
 return $pageURL;

}
$test = explode("=",curPageURL());
$t1 = $test[1];

$term2 = $_POST['term2'];
//$term = $_POST['term'];
if ($term2 !="") {
$term2 = $_POST['term2'];

} else {
$term2 = $t1;
}
for posterity

Re: add a variable from a url into code for posting purposes

Posted: Sat Apr 28, 2012 3:34 am
by requinix
Seriously?

Code: Select all

$t1 = $_GET["file_id"];

Re: add a variable from a url into code for posting purposes

Posted: Sat Apr 28, 2012 7:58 pm
by inosent1
:oops:

well, at least it was a nice little seminar on curl :)

Re: add a variable from a url into code for posting purposes

Posted: Sat Apr 28, 2012 9:53 pm
by califdon
inosent1 wrote:well, at least it was a nice little seminar on curl
No, that has nothing to do with curl. It's just basic PHP.
http://www.w3schools.com/php/php_get.asp