Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,152,902 members, 7,817,673 topics. Date: Saturday, 04 May 2024 at 04:57 PM

[PHP] [HOWTO] Send 'POST' Data Through Header ?? - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / [PHP] [HOWTO] Send 'POST' Data Through Header ?? (4128 Views)

Howto Query Webpayinterswitch Transaction Status Using Wordpress(wp_remote_get) / How To Add Header Image To Blogger / Help Needed!!! Content Appearing Behind Fixed Header (2) (3) (4)

(1) (Reply) (Go Down)

[PHP] [HOWTO] Send 'POST' Data Through Header ?? by Gerardcole(m): 5:47pm On May 29, 2013
To our ogas at the top. I need you guys to help out on this.

I need to send a 'POST' data to another page page on my site by redirection. I don't wanna use a JavaScript cos the user might have JavaScript turned of.

I do not also wanna use a 'GET' cos it will affect the beauty of the project.

I've considered using 'COOKIE' that lasts for 10 seconds. But the bad part is, if a user loads two pages within that 10 seconds, the string is shown on both(this also applies to 'SESSION'). Perhaps the user might not even cookie accepting turned on.

What I'm saying is something like
header('Location: /folder/?foo=bar');

But the ?foo=bar makes it 'GET'. I a 'POST' alternative.
Re: [PHP] [HOWTO] Send 'POST' Data Through Header ?? by yawatide(f): 8:35pm On May 29, 2013
even your foo=bar scenario isn't technically a GET, in this context.

If i understand what you mean then if you aren't within the context of a form, I don't think you can send anything via POST, but I could be wrong.
Re: [PHP] [HOWTO] Send 'POST' Data Through Header ?? by sabams08: 9:51pm On May 29, 2013
The best option u have is using the header() function.
How does the GET affect the beauty of ur site?
Re: [PHP] [HOWTO] Send 'POST' Data Through Header ?? by Nobody: 11:07pm On May 29, 2013
iThink its possible with cURL..

http://davidwalsh.name/curl-post
Re: [PHP] [HOWTO] Send 'POST' Data Through Header ?? by talk2hb1(m): 12:43am On May 30, 2013
Judinho59: iThink its possible with cURL..

http://davidwalsh.name/curl-post
I think curl library only support POST method only. You create the receiving end like an API that the curl function can call and pass data to.
Re: [PHP] [HOWTO] Send 'POST' Data Through Header ?? by mitey(m): 11:16am On May 30, 2013
Why not create a form on the page and assign all the values you want to pass to hidden inputs then use post to send it when the user submits the page?

For example
<form action="newpage.php" method="post" ... >
<input type="hidden" name="variable1" value="x" />
<input type="hidden" name="variable2" value="y" />
<input type="hidden" name="variable3" value="z" />
</form>


Then on newpage.php, you have
<?php
if($_POST['variable1']) {
$variable1 = $_POST['variable1'];
}
if($_POST['variable2']) {
$variable2 = $_POST['variable2'];
}
if($_POST['variable3']) {
$variable3 = $_POST['variable3'];
}
...
?>
Re: [PHP] [HOWTO] Send 'POST' Data Through Header ?? by yawatide(f): 12:26pm On May 30, 2013
^^^ I thought OP says he is using redirection. Also, even if it were doable based on your code above, you probably want to use REQUEST and not POST, for security reasons.
Re: [PHP] [HOWTO] Send 'POST' Data Through Header ?? by gothrones(m): 6:40pm On May 30, 2013
I do not understand what you intend to achieve. Could you please give us a thorough walk-through? Is this the scenario that you seek:

1) User enters data on form
2) User POSTs data to server (which is processed by page X)
3) You then desire to redirect to page Y, wherein Y will have the POST data of X

?
Re: [PHP] [HOWTO] Send 'POST' Data Through Header ?? by mitey(m): 7:03pm On May 30, 2013
^^^Right @OP. Tell us what the initial page does and the data type you intend to pass over to the next page. That way we can better help you.
Re: [PHP] [HOWTO] Send 'POST' Data Through Header ?? by Gerardcole(m): 8:03pm On May 30, 2013
Okay. Thanks everyone.

For the records I simply disagree with $_REQUEST cos it checks. POST, GET, COOKIE. Which isn't very professional. You should know what you are fetching. Or make it conditional.

The thing is like this.

User fills form targeting page1.

Page1 processes the input and passes the data to page 2.

Page two has its own form. And its based on what Page1 passes to it.

And I don't want users to know about this.
Re: [PHP] [HOWTO] Send 'POST' Data Through Header ?? by gothrones(m): 9:14pm On May 30, 2013
^
Why not just combine pages 1 and 2 into one single file?
Re: [PHP] [HOWTO] Send 'POST' Data Through Header ?? by Nobody: 9:18pm On May 30, 2013
Page 2 seems to be from another server, not op's website.. Mayb u're trying to do something about sms.
Re: [PHP] [HOWTO] Send 'POST' Data Through Header ?? by gothrones(m): 11:57pm On May 30, 2013
^
Gerardcole: I need to send a 'POST' data to another page page on my site by redirection...
Re: [PHP] [HOWTO] Send 'POST' Data Through Header ?? by Nobody: 8:08am On May 31, 2013
gothrones: ^

@OP, am still cofused here.. Give an example
Re: [PHP] [HOWTO] Send 'POST' Data Through Header ?? by Gerardcole(m): 9:00am On May 31, 2013
Thanks everyone. I have resolved to use GET.

After about 1 hour searching, I saw there are some people who wants what i want but there's no possibility to that. The only option was using COOKIE. Which I don't really trust.

Once Again Thanks.

(1) (Reply)

Which Content Management System Is Good For Blogging / It's Hard For Me To Live As An Upcoming Blogger. Why? / 4 Ways To Optimize Your Website For Google Mobile Indexing

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 20
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.