Solved

Convert $_GET $tring to $_POST $tring?

Posted on 2004-08-04
9
1,292 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 36

Expert Comment

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

Regards,
${Zyloch}  
0
 
LVL 27

Accepted Solution

by:
Diablo84 earned 84 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 83 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 18

Assisted Solution

by:arantius
arantius earned 83 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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 …

632 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