add a variable from a url into code for posting purposes

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

add a variable from a url into code for posting purposes

Postby inosent1 » Fri Apr 27, 2012 6:46 pm

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
inosent1
Forum Commoner
 
Posts: 97
Joined: Wed Jan 28, 2009 1:18 pm

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

Postby inosent1 » Fri Apr 27, 2012 7:54 pm

Syntax: [ Download ] [ Hide ]
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
inosent1
Forum Commoner
 
Posts: 97
Joined: Wed Jan 28, 2009 1:18 pm

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

Postby requinix » Sat Apr 28, 2012 3:34 am

Seriously?
Syntax: [ Download ] [ Hide ]
$t1 = $_GET["file_id"];
Did you steal it?
User avatar
requinix
Spammer :|
 
Posts: 5513
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

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

Postby inosent1 » Sat Apr 28, 2012 7:58 pm

:oops:

well, at least it was a nice little seminar on curl :)
inosent1
Forum Commoner
 
Posts: 97
Joined: Wed Jan 28, 2009 1:18 pm

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

Postby califdon » Sat Apr 28, 2012 9:53 pm

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
I don't make syntax errors. It's just that sometimes whoever wrote the programming language failed to anticipate my creative coding.
User avatar
califdon
Jack of Zircons
 
Posts: 4484
Joined: Thu Nov 09, 2006 9:30 pm
Location: California, USA


Return to PHP - Code

Who is online

Users browsing this forum: Yahoo [Bot] and 9 guests