Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 151953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:32:12+00:00 2026-05-11T09:32:12+00:00

I found the following code on here that I think does what I want,

  • 0

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).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T09:32:13+00:00Added an answer on May 11, 2026 at 9:32 am

    The header function is used to send HTTP response headers back to the user (i.e. you cannot use it to create request headers.

    May I ask why are you doing this? Why simulate a POST request when you can just right there and then act on the data someway? I’m assuming of course script.php resides on your server.

    To create a POST request, open a up a TCP connection to the host using fsockopen(), then use fwrite() on the handler returned from fsockopen() with the same values you used in the header functions in the OP. Alternatively, you can use cURL.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 67k
  • Answers 68k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Well, What I'd do is, like you said, a web… May 11, 2026 at 12:04 pm
  • added an answer To temporarily disable a constraint (foreign keys are constraints): ALTER… May 11, 2026 at 12:04 pm
  • added an answer I actually got it solved by getting each control self-registered… May 11, 2026 at 12:04 pm

Related Questions

I was reading a book on templates and found the following piece of code:
I found the following code to create a tinyurl.com url: http://tinyurl.com/api-create.php?url=http://myurl.com This will automatically
According to what I have found so far, I can use the following code:
I was just reviewing some old code and found the following (inside foo.asp): Const
Following the JSONRequest proposa l, I've found code for the JSONRequest object . However,
I found the following rather strange. Then again, I have mostly used closures in
I'm converting an application to use Java 1.5 and have found the following method:
When reviewing our codebase, I found an inheritance structure that resembles the following pattern:
I’ve just found out that the execution plan performance between the following two select
So: I have the following function, adapted from a formula found online, which takes

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.