Sending POST data from one PHP file to another

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

Post Reply
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Sending POST data from one PHP file to another

Post by Gen-ik »

Hi, guys.


Is it possible to send POST data from one PHP file to another?

Code: Select all

<?php

header("content-type:application/x-www-form-urlencoded");

// add variables

header("location:target.php");

?>
If it is not possible then no problem. If it is possible could someone please supply a little example of how I would send the variable data. :)


Thanks,
Si ++
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Through redirection, no. Through cURL, yes. However, if the end file is on your server, why not pass it through sessions?
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

feyd wrote:Through redirection, no. Through cURL, yes. However, if the end file is on your server, why not pass it through sessions?
Good point. :D
Totally obvious thing to do really.

Thanks, mate.
phpCCore Brad
Forum Commoner
Posts: 47
Joined: Sun Dec 04, 2005 5:46 pm
Location: Michigan, USA
Contact:

Post by phpCCore Brad »

I actually have a question along the same lines... I was working on a search engine optimizer which takes forwards anything from a specific directory to a php script. With .htaccess. However since the .htaccess doc is not php is there a way to transfer the request vars to the php script using htaccess?
Post Reply