I have to program an application where the users can connect to other websites. For example, the user clicks on the "Amazon" button and the application opens the Amazon website. It then needs to pre-populate the login and password information for the user. (The user added that info to my data base previously.)

My application is in PHP. I have tried using curl to implement this. I can connect, but the cookie is not then used by the users browser. My problem is a lot of websites are protected with tokens and their is a wide variety of different URLs

I have also tried another solution: the application would only fill in the user and password and the user click on "validate" or "login". After researching this, I've found that it may be more difficult. I haven't found any explication about how to fill a form in another website. I think browsers can do it, and I've seen applications such as 'Dashlane' that can do it to, so I think it should be possible.

How do I implement this feature?

  • I put a link to the website then there are 2 options: 1) I send login and password with a form to the website server for connect the user 2) I fill login and password to the other siteweb client and the user click on "validate". Mozilla Firefox do the second method but it's a navigator... Can you help me please?
    – Deyanos
    May 21, 2015 at 11:31
  • The users of this application use a lot of websites. For the websites, they have a difficult login and a password of 16 characters, so it's very difficult for them and they waste time. My mission is save employeer's time. When they are in their website, they just do what they need, my application don't look it. I ask how I log or how I can fill the differements inputs for them (Firefox do it, Dashlane too, but I don't know how they works)
    – Deyanos
    May 21, 2015 at 13:51
  • 1
    "so I think it should be possible" - using a browser, browser extension or installed application on the client's machine - yes. However, it sounds like you are wanting to do this from one website to another arbitrary website?
    – MrWhite
    May 23, 2015 at 21:35

2 Answers 2


You're on the right track with CURL.

What you need to do is add code that reads the website as if it's a basic HTML file then process the file replacing certain HTML code.

If some websites are basic with little to no javascript and contain a login box, then look for code containing something like:

<input type="text" name="username">

and replace it (using PHP's str_replace) with:

<input type="text" name="username" value="importedusername">

and do the same with the password field:

<input type="password" name="password">

and replace it (using PHP's str_replace) with:

<input type="password" name="password" value="importedpassword">

Here's a script to help you get started provided your PHP config is set to allow URLs in file functions, and that the website codes the username and password like I coded it above:

$webpage=str_replace('<input type="password" name="password">','<input type="password" name="password" value="'.$mypass.'">',$webpage);
$webpage=str_replace('<input type="text" name="username">','<input type="text" name="username" value="'.$myuser.'">',$webpage);
echo $webpage;

Because website publishers are free to order the parameters in the HTML tags to their liking, the code I present may need to be modified in order to adapt to each site.

For example, They could use:

<input name="username" type="text">

instead of:

<input type="text" name="username">

and if they do that, my code will then need to be modified.

Also, my code does not add any HTML headers. You should however define some with the header() command for better output speed. and place them before the final echo statement in my code.

  • Thank you for your answer ! I have already done it. I use DomElement, a PHP's library. With DomElement, I can use the html as javascript (fonctions getElementsByTagName etc.). When the website use a token system there are 2 tokens: 1 in a cookies when you visit the page, and the other in the form. The tokens need to be equal, but with this method they aren't. I have form's token in my form, so file_get_contents don't use cookie of browser.
    – Deyanos
    May 22, 2015 at 7:26

I have maybe a solution. VBScript could fill login, because it can to have action on system.

<script language="VBScript">
    document.write "<h1>Et ceci du VBscript</h1>"
     Set objIE = CreateObject("InternetExplorer.Application")

    objIE.Navigate "about:blank"
    objIE.Visible = true
    objIE.Navigate "www.google.com"


But I put this code in a html page and I open this page with IE. So i don't want it create a new IE.application. I want it use the IE opened.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.