Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Convert $_GET $tring to $_POST $tring?

Posted on 2004-08-04
9
Medium Priority
?
1,304 Views
Last Modified: 2012-08-14
I have an java app that will send a url sting (domain.com/login.php?user=username&pass=password&etc...) to automaticly login to one site.  The other site only looks at $_Post[user] to get the login info.  I do not want to change the second website login method but i do want to login.  

Q: Is there a way I could make a script to take my url $tring [$_GET] and turn it into a post string [$_POST]?

0
Comment
Question by:greyhair
6 Comments
 
LVL 36

Expert Comment

by:Zyloch
ID: 11721291
Use $_REQUEST['name']

Regards,
${Zyloch}  
0
 
LVL 27

Accepted Solution

by:
Diablo84 earned 336 total points
ID: 11721385
you really should not send passwords in the url query string, can you not set up your java app to send the data via post
0
 
LVL 25

Assisted Solution

by:Marcus Bointon
Marcus Bointon earned 332 total points
ID: 11721509
Using $_REQUEST would require him to change the code on the receiving site, which he said he can't do.

You could write a proxy that converts an HTTP GET to a POST, accepting the GET request and generating a new POST request using CURL, then passing the results back to the original requester. Roughly like this:

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.postdomain.com/login.php'); //Set to your target URL
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $_SERVER['QUERY_STRING']);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
$result = curl_exec($ch);
curl_close($ch);
?>

The curl_exec will just dump whatever comes back from this POST request to the original GET requester. You might need to a be a little more careful with what you pass into CURLOPT_POSTFIELDS, but the principle should hold together. You may also need/want to pass through various other info from the original requester (in the same way as I have with user agent). Also bear in mind that this route will make it look like your server rather than the requester is the real requester, which may mean that the log works, but only for your server's IP address, depending on how they have their login script set up.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 18

Assisted Solution

by:arantius
arantius earned 332 total points
ID: 11743466
Point your java app to this PHP page, and this form's action to the real app:


<html>
<head>
<title>whatever</title>
</head>
<body>

<form method="post" action="http://......../">
<?
foreach ($_GET as $key => $value) {
  printf("<input type=\"hidden\" name=\"%s\" value=\"%s\" />", $key, $value);
}
?>
<button type="submit">Continue login...</button>
</form>
</body>
</html>
0
 

Expert Comment

by:savtrad
ID: 23359211
You can use Java Script to submit a form with Post values activated by a hyper link. This will give you a hyper link appearance which will submit form vaues using the post menthod.
Place this java script between your head tags. Use hidden input form fields for additioal post values sent by the java script activated submit action.

<html>
<head>
<title>Title</title>
<script language="JavaScript" type="text/javascript">
<!--
function submitlink ( postvalue )
{
  document.linkform.area_session.value = postvalue ;
  document.linkform.submit() ;
}
-->
</script>
 
</head>
<body>
<form name="linkform" action="/index.php" method="POST" >
    <input type="hidden" name="area_change" value="Change" />
    <input type="hidden" name="area_session" />
    <a href="javascript:submitlink('Members_Area')">Members Area</a><br />
    <a href="javascript:submitlink('Free_Area')">Free Area</a><br />
                        </form>
</body>
</html>

Open in new window

0
 
LVL 36

Expert Comment

by:Zyloch
ID: 23359319
Wow, this is so old. Back in the times when I was still young and naive =)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
This article discusses how to implement server side field validation and display customized error messages to the client.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question