Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The problem is that when you use CURL to post it's your <strong>web server</strong> that's posting, not the user's browser. So if any sessions or cookies are being used they won't carry over.</p> <p>I'd do what you mentioned, creating a hidden form and posting the data that way. You could be clever about it though and do a document.ready in jQuery and as soon as the hidden form is loaded you could post it for the user. While there is still a small window of opportunity for them to view source it'd be a little more stream-lined.</p> <pre><code>&lt;script&gt; $(document).ready(function() { $('#hiddenForm').submit(); }); &lt;/script&gt; </code></pre> <p><strong>Edit</strong> Full example:</p> <pre><code>&lt;? $urlToPostTo = 'http://www.thirdPartyDomain.com/login'; $varsToPost['user'] = 'username'; $varsToPost['pass'] = 'password'; ?&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt; &lt;script&gt; $(document).ready(function() { $('#hiddenForm').submit(); }); &lt;/script&gt; &lt;? echo '&lt;form id="hiddenForm" action="'.$urlToPostTo.'" method="post"&gt;'; /* create a hidden input for each var in 'varsToPost' */ foreach($varsToPost as $varName=&gt;$varValue) { echo '&lt;input type="hidden" name="'.$varName.'" value="'.$varValue.'"&gt;'; } echo '&lt;/form&gt;'; ?&gt; </code></pre> <p>Just add / remove variables in the <code>$varsToPost</code> array and they'll automatically be plugged in. I guess if you were passing a password / sensitive data you could always encrypt it in php and decrypt it in js right before the form submit. This would still leave you open as anyone would have access to your decrypting function but it'd mask your data at a glance.</p> <p>Even so, this form submit happens very quickly, it's hard to tell that it's being sneaky.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload