There is a another-site such as :

there is a form on

To access this page we need to go through login from


Now i have my site - http://my-site.com/
i do have the login information for his-site
i need to auto-login and access the form page of his-site from my-site
like http://my-site.com/submit_to_his-site.do

How do i create the authentication to his-site without logging to his page.
all the things should be hidden inside my-site.

its Like -
The user will come to my-site and login.
He will use my-form to submit to 's form


Now I can do everything except the POST operation for the login to

IFRAME and Ajax can solve my problem in a way
but i need some more robust work flow.
coz i'll be using this on cron job.

Dani AI

Generated

Short answer: what you want is done on the server by creating a real HTTP session with the other site, then posting the form while reusing that session. is right that you cannot change the target site without access to it, but you do not need to embed the other site in the browser to submit on behalf of a user. For a robust cron-driven workflow you must: reproduce the login flow (GET login page, extract any hidden tokens), POST credentials, save the session cookie(s), then POST to the target form using the same cookies. Be aware that captchas, two‑factor auth, or bot protection will block automation and may make this impossible without the other site's cooperation.

A concise PHP workflow using a modern HTTP client looks like this. It keeps cookies, fetches the login page to get any hidden token, logs in, then posts to the submit endpoint:

<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
use GuzzleHttp\Cookie\CookieJar;

$jar = new CookieJar();
$client = new Client(['cookies' => $jar, 'headers' => ['User-Agent' => 'MyCron/1.0']]);

$loginHtml = (string)$client->request('GET', 'https://target.example/login', ['cookies'=>$jar])->getBody();
// extract CSRF token from $loginHtml (DOM or regex)
$client->request('POST', 'https://target.example/login', [
  'form_params' => ['username'=>getenv('TARGET_USER'),'password'=>getenv('TARGET_PASS'),'csrf'=>$token],
  'cookies' => $jar,
  'allow_redirects' => true
]);

$resp = $client->request('POST', 'https://target.example/submit', [
  'form_params' => ['field1'=>'value1'],
  'cookies' => $jar
]);
echo $resp->getStatusCode();

Troubleshooting checklist: capture the real browser request via devtools to see every field and header, verify you are preserving cookies and following redirects, parse and supply hidden CSRF fields, and log responses (status codes and body) so cron runs can be debugged. For cron use a CLI script, keep credentials in environment variables or a secrets store, and write clear retry and error handling.

Caution: confirm the target site's terms and get permission where required. Prefer an official API or OAuth token if available. Store secrets securely, use HTTPS, and respect rate limits.

Recommended Answers

All 5 Replies

ok here is some more in detail

has database
and also the form to insert data to his-database

my-site.com will also have the HTML form.
but the post from the my-site will go to his-site.


All this things should happen inside the server
the user should not get clue about

I think that you would need access to his site to place code on the page you want secured.

look its like ...

i will make a chat-room based on the this forum we are using

but the user will have have to type the http://www.daniweb.com/ on URL

but we know ... to reply or to post in this forum we need to login to this site. isn't so???

now i need to submit to some post from my-site ... with logging from my-site ...


how??

OK suppose

you save your hi5 login account to my-site.
when you change the profile Status (Scrapbook) of my-site then it must automatically change on your profile of hi5

:D
its all me in this post
:D

curl does these all for you
for more info:
http://php.net/curl


Thanks all

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.