I try to curl a page with a javascript submit process with out any luck… So I ask the community for some help!
Here is the form :
<script>
<!--
function vallogin(){
document.formlogin.action = "./index.php?vallogin=1";
document.formlogin.submit();
}
-->
</script>
<form name="formlogin" method="post">
<div class="headerblocgris">
<span class="txtnoir12">| Accès |</span>
</div>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="txtnoir12">Login</td>
<td><input name="txtlogin" type="text" size="15" /></td>
<td><span class="txtnoir12">Password</span></td>
<td>
<input name="txtmdp" type="password" size="15" />
<input type="image" name="vallogin" src="images/bt_go.gif" align="absmiddle" />
</td>
</tr>
</table>
</form>
And my curl function :
{
/**
* Connexion
*/
$URL = 'http://www.affiliatevista.com/index.php?vallogin=1';
$data = array(
'txtlogin' => $this->login,
'txtmdp' => $this->passe,
'formlogin' => '',
'vallogin' => '',
);
curl_setopt($this->ch, CURLOPT_URL, $URL);
curl_setopt($this->ch, CURLOPT_HEADER, true);
curl_setopt($this->ch, CURLOPT_POSTFIELDS, $this->implode_array($data));
curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->ch, CURLOPT_COOKIEJAR, $this->_getCookie());
curl_setopt($this->ch, CURLOPT_COOKIEFILE, $this->_getCookie());
curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, true);
$String = curl_exec($this->ch);
echo $String;
}
Thanks for your input, the code above doesn’t validate the form, I think I miss something with the submit validation process…
I think you need to call the vallogin() function?
I don’t see a submit button in your code, so something like:
might work.
Using JQuery and AJAX to do a post then return a result might be a better option though.
http://api.jquery.com/jQuery.post/
Or it could be you need an onsubmit=”vallogin()” in your form attributes.