Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have previously used PHP CURL to submit web forms by using the post URL.

I'm trying to automate the process of logging into a website, I can't change server side code.

The submit button on the HTML form uses the action of javaScript:submitForm() how can I submit information to this form using PHP.

Is CURL still an option?

Thanks!

share|improve this question
1  
"logging into a website, which I don't own, so I can change the server side code." That seems like a Bad Thing™. Perhaps you should clarify your intentions. – George Cummins 16 hours ago
1  
I can't change server side code is what I meant. – Jack 16 hours ago

2 Answers

You'll need to find the function declaration for submitForm and see where it is posting to. Then you can use php and curl to submit.

Edit: Since the submitForm function doesn't change the form action, you can still use the action in the form tag.

share|improve this answer
Please check my updated post... – Jack 16 hours ago

Regardless of how client-side code is crafting the form submit, it still needs to send an HTTP request to the server. If you can do this manually by interacting with the site in question, then capture that request using browser debugging tools (FireBug, Chrome dev tools, etc.). That should have all of the information needed to craft a custom request of your own.

Note, however, that the website in question might have measures in place to prevent something like this. Especially if they're using a framework that handles the form posts for them (such as ASP.NET WebForms or anything like that). They may be emitting a form field to the page which contains a one-time-use token to be validated in the subsequent form submit request. If that's the case, any time you want to craft an automated form submit you'll first need to craft an automated request to parse out that token so you can use it in your submit.

If they take even more involved measures to prevent what you're doing, then you're going to have more of an uphill battle automating it.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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