Forum Moderators: coopster
I'm a total noob to PHP.
Can anyone explain or give me an example of how I would process a POST similar to this:
POST /pathfromdeveloper HTTP/1.1
Content-Type: application/www-url-encoded
Content-Length: 120
Host: hostfromdeveloper
PIN=12341234&email=customeremail@email.com&product=product&version=1.2&transact
ionid=123&test=false
I would need to read it in as a string, but I'm not even sure how to do this?
How can I then send a response back?
THanks!
The information I've been told is:
On request the portal will do an HTTP post to the indicated URL:
http://www.example.com/#*$!.php
The request is as follows:
POST /pathfromdeveloper HTTP/1.1
Content-Type: application/www-url-encoded
Content-Length: 120
Host: hostfromdeveloper
PIN=12341234&email=customeremail@example.com&product=product&version=1.2&transact
ionid=123&test=false
Does that make sense?
[edited by: coopster at 10:53 am (utc) on Mar. 19, 2009]
[edit reason] please use example.com, thanks! [/edit]
PIN=12341234
email=customeremail@email.com
product=product
version=1.2
transactionid=123
test=false
If that is the case, then you should be able to access those using the following syntax: $_POST['variablename'].
So, you would access each variable like this:
$_POST['PIN']=12341234
$_POST['email']=customeremail@email.com
$_POST['product']=product
$_POST['version']=1.2
$_POST['transactionid']=123
$_POST['test']=false
You can see that each variable still contains the same information, we're just telling PHP to look in the POST variable array to find the specific values.
So, entering:
echo $_POST['PIN'];
would write to the page:
12341234
Does any of that make sense?
I need to use the PIN variable and manipulate the number and generate a key from this. I think I can figure this out myself, but then I have to send a response with my 'key'.
The response needs to be in the format:
HTTP/1.1 200 OK
Content-Type: application/www-url-encoded
Content-Length: 20
key=ABCDEFGHIJK
Any ideas on how to do this? Is Content-Type going to be a variable name, in which case I would just read that from the POST and place the same string in the response?
Thanks a lot!
HTTP/1.1 200 OK
Content-Type: application/www-url-encoded
Content-Length: 20
is just a page header. I'm not sure how to manipulate it. If you knew how the page that will be receiving the information will be processing it, it would be easier to say how to send it.
EDIT: Now that I think about it, it looks like that data needs to be sent via POST, as well. I'm not sure how to spoof some POST headers, so I would just use javascript to auto submit a form, but I'm sure someone else here could answer better.
EDIT2: I found something about opening a socket connection. Try using Google to search for something like PHP HTTP Socket.