Okay, following problem:
When a user hits submit on a form, I want to call a php script that processes the data entered in said form and makes some changes to a mySQL database. So far so good; I managed to do that.
However, then I want to call the same script again, just with a certain variable set to a certain value.
Reason is that I only use this one script file for all functions by setting a variable called "useraction" to a certain value, like "subscribe" or "unsubscribe". This is nromally done with mini-forms only containing a sumbit button and a hidden input tag bearing "useraction" as the name and "subscribe" etc. as the value.
problem is: how do I code it in PHP with headers that I can use the POST method to transmit such a variable?
To make that clear:
1. user clicks on form, which is submitted
2. script is called with "useraction" set to "subscribe"
3. script processes form information and makes database changes
4. script calls itself with "useraction" set to "showlist"
My attempt so far was this:
$data = urlencode("useraction")."=".urlencode("showlist")."&";
$header = "Location: POST http://www.domain.tld/user/action.php HTTP/1.0\n";
$header .= "Host: www.domain.tld\n";
$header .= "Content-type: application/x-www-form-urlencoded\n";
$header .= "Content-length: " . strlen($data) . "\n";
$header .= "\n".$data;
header($header);
Can anybody help me? I've tried to understand the RFC2616 about the HTTP protocol, but it's too complicated for me.
Any input would be appreciated, thanks.