Solved

PHP Curl, To Fill in a input field and click a button.

Posted on 2011-03-24
2
900 Views
Last Modified: 2012-08-14
Can anybody tell me if the following is possible:

Can I use PHP curl to target a input field, fill in some text then execute a button click or JavaScript function within the loaded page?

If so... How?

This is not a regular form with POST methods....

Form that I'm trying to process remotely
<div class="IngeniMailSubscribeContainer" id="IngeniMailSubscribeContainer_430321" align="center">
   <div style="margin-bottom: 8px;">
	 <span class="subhead">Your email:</span>
	 <input class="IngeniMailSubscribeEmailInput" type="text" size="20" id="IngeniMailSubscribeEmailInput_430321" value="" /> 
   </div>
   <input class="IngeniMailSubscribeButton" type="button" value="Subscribe" onclick="MailSubValidateSubmit_430321();" />
   <div id="MailSubscribeError_430321" align="left" class="normalred"></div>

</div>

<script type="text/javascript">
function MailSubValidateSubmit_430321()
{
    
	document.getElementById('MailSubscribeError_430321').innerHTML = '';
	var inputId = 'IngeniMailSubscribeEmailInput_430321';

	var Input = document.getElementById(inputId);
	var val = '' + Input.value;
	var rx = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/ig;
	var matches = rx.exec(val);

	if (matches != null && val == matches[0]) {
		MailSubscribe.MailSubscribeClick(430321,240570);
	}
	else {
		document.getElementById('MailSubscribeError_430321').innerHTML = 'Invalid email';
	}
}

function MailSubUnsubscribe(email)
{
	var Container = document.getElementById('IngeniMailSubscribeContainer_430321');
	Container.innerHTML = "<input id='IngeniMailSubscribeEmailInput_430321' type='hidden' value='" + email + "'/>";
	MailSubscribe.MailSubscribeClick(430321,240570);
}
</script>

Open in new window

0
Comment
Question by:Cybervanes
2 Comments
 
LVL 38

Accepted Solution

by:
Aaron Tomosky earned 500 total points
ID: 35211691
Curl does post and get. It doesn't do JavaScript clicks.
0
 
LVL 2

Author Closing Comment

by:Cybervanes
ID: 35890995
answer would work but dint hit on the specifics of the question
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

This article discusses four methods for overlaying images in a container on a web page
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now