Page 1 of 1
Sending $_POST['field'] via browser window and PHP?
Posted: Mon Dec 06, 2004 8:36 pm
by Mr Tech
Hey there,
I want to be able to open a PHP page in a browser window which then redirects to another website but also sending a $_POST['field'] without the use of a form.
Any ideas on how I can do this? I've seen it done with ASP.
Thanks
Ben
Posted: Mon Dec 06, 2004 8:36 pm
by protokol
Put it into the query string. Treat it like a $_GET
Posted: Mon Dec 06, 2004 8:42 pm
by Mr Tech
But I want it to be hidden.... is it possible?
Posted: Tue Dec 07, 2004 12:28 pm
by protokol
Posted: Tue Dec 07, 2004 12:51 pm
by xisle
you can use a hidden input variable, and a form with no button
use JS to open a new window and target the results of the post
Code: Select all
//JS code
window.open('','results','toolbar=0,width=50,height=50');
document.formї0].target = 'results';
document.formї0].submit();
Posted: Tue Dec 07, 2004 4:02 pm
by Mr Tech
I don't think i want to use JS:
viewtopic.php?t=28161
viewtopic.php?t=7063
I don't think they are what I need. I don't want to just send a post value but I also want to redirect them page to the page I am sending the post value too.
The reason why I want this is becuase when they login to their script, it then sends them to my website checking their license key.
If the license is valid, it redirects back to the referring website, sending a POST. Once they get back to their script, the script will set a session() with that POST, enabling them, to use the script.
If its not valid, it will send another POST saying that it's not valid.
I suppose this is the sort of thing I would need but I don't know how to get it working:
Code: Select all
<?php
header("POST /index.html HTTP/1.1");
header("Host: http://www.algirdas.com");
header("User-Agent: Mozilla/4.0");
header("Content-Length: 23");
header("Content-Type: application/x-www-form-urlencoded");
print("merchant_account_id=223");
?>
Thanks for the help!
Posted: Wed Dec 08, 2004 2:12 am
by mchaggis
Here is another idea for you...
You could use curl or one of the other file opening functions, that allow you to open urls from within a php, thus no need for you to redirect them, which would also mean that you could do away with the need to post.
Code: Select all
<?
if (!eregi('License Valid',file_get_contents("http://www.algirdas.com/?merchant_account_id=223"))) {
# License is invalid... do something
Header("Location: Invalid.html");
}
?>
Posted: Wed Dec 08, 2004 2:18 am
by Mr Tech
Thanks mchaggis,
That is a good idea, however, some hosts block that from happening....
Any thoughts?
Cheers,
Posted: Wed Dec 08, 2004 2:23 am
by Mr Tech
I gave you code a whirl anyway and am getting this error:
Parse error: parse error, unexpected $ in c:\program files\easyphp\www\created\post\check.php on line 7
Heres the code:
Code: Select all
<?
if (!eregi('License Valid',file_get_contents("test.php?valid=no"))) {
echo "valid";
} else {
echo "not valid";
?>
?>
Wots wrong with that?
Posted: Sat Dec 11, 2004 8:27 pm
by Bennettman
Missing end bracket at the end. You don't need any brackets if you've only got one command to run in an if/else anyway.
Posted: Fri Dec 17, 2004 10:59 pm
by Mr Tech
LOL how did I miss that... Seems to work fine now thanks
