KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I found the following code on here that I think does what I want, but it doesn't work: $host = "www.example.com"; $path = "/path/to/script.php"; $data = "data1=value1&data2=value2"; $data = urlencode($data); header("POST $path HTTP/1.1\r\n"); header("Host: $host\r\n"); header("Content-type: application/x-www-form-urlencoded\r\n"); header("Content-length: " . strlen($data) . "\r\n"); header("Connection: close\r\n\r\n"); header($data); I'm looking to post form data without sending users to a middle page and then using JavaScript to redirect them. I also don't want to use GET so it isn't as easy to use the back button. Is there something wrong with this code? Or is there a better method? Edit I was thinking of what the header function would do. I was thinking I could get the browser to post back to the server with the data, but this isn't what it's meant to do. Instead, I found a way in my code to avoid the need for a post at all (not breaking and just continuing onto the next case within the switch).
Tags (comma-separated)
Save Edits
Cancel