Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7652317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:44:12+00:00 2026-05-31T11:44:12+00:00

This problem is keeping me busy all week and I find little to nothing

  • 0

This problem is keeping me busy all week and I find little to nothing on the net …

What I want to do is simple … on my own website, create a server side PHP script that makes a login to another website with valid credentials and downloads a file that I want to process.

I use curl_init(), curl_setopt() and curl_exec() in trying to achieve that. It doesn’t work.

So I stripped down that webpage to figure out what’s wrong.
As you can see in the html code, the form’s action event is the url to retrieve the file, when correct credentials are submitted.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >

<body>
<form name="form1" method="post" action="http://otherwebsite/login.aspx?ReturnUrl=/export_file.aspx?id=xxxxxxx" >
<script type="text/javascript" language="JavaScript">
        function Submit_Form()
        {
           document.form1.Login$UserName.value="myname";
           document.form1.Login$Password.value="mypassword";
           //document.form1.Login$LoginButton.click();
           document.form1.submit();
        }
</script>

<input type="hidden" name="Login$UserName" value="myname" />
<input type="hidden" name="Login$Password" value="mypassword" />

<input name="Login$LoginButton" type="submit" />
<br /><a href="javascript:Submit_Form();">Login</a>

</form>
</body>
</html>

Now here is where it gets weird.
If I press the button, it works and I receive the download file.
If I click the hyperlink, i get a page saying to login properly.
When I uncomment the javascript line : click() it works too.

So it comes down to this :
Why does the button submit work and javascript submit doesn’t work ?
Is there a way that the other website’s server check how the form was posted ?
Thank you for your thoughts !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T11:44:13+00:00Added an answer on May 31, 2026 at 11:44 am

    When you click the button, its name is included in the POST request because it’s a named submit button. When you use the link, the button’s name doesn’t get passed in the POST data.

    You could probably spoof the button when you use the link by having a hidden field with the name the button should have:

    <input type="hidden" name="Login$UserName" value="myname" />
    <input type="hidden" name="Login$Password" value="mypassword" />
    <input type="hidden" name="Login$LoginButton" />
    

    Note it doesn’t need a value because the button it replaces doesn’t have a value setting its text. Just including it should be sufficient.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This problem seems very simple to me, but I've been unable to fix it,
I'm just starting to approach this problem, I want to to allow users to
I'm new to Struts 2 and facing this problem in keeping the layout of
I'm having a problem keeping the contents of this table within it's container: See
I am trying to create a upload plugin. I am keeping all the logic
I want to filter out all values of var3 < 5 while keeping at
So there seems to be this problem with GNU Make's $(wildcard) function keeping a
This problem is same as asked in here . Given a list of coins,
This problem is caused by my acknowledge of English and jQuery or maybe something
This problem has been bugging me for a long time. For example, the code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.