Curl 和 javascript 提交

发布于 2024-10-19 13:41:40 字数 1953 浏览 0 评论 0原文

我尝试使用 javascript 提交过程来卷曲页面,但没有任何运气......所以我向社区寻求一些帮助!

这是表单:

<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> 

我的curl函数:

{
         /**
         * 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;
    }

感谢您的输入,上面的代码没有验证表单,我想我错过了提交验证过程的一些内容......

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...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

剪不断理还乱 2024-10-26 13:41:40

我认为您需要调用 vallogin() 函数?

我在您的代码中没有看到提交按钮,因此类似:

<input type="submit" value="Login" onclick="vallogin(); return false" />

可能有效。

不过,使用 JQuery 和 AJAX 进行发布然后返回结果可能是更好的选择。

http://api.jquery.com/jQuery.post/

或者它可能是你需要的表单属性中的 onsubmit="vallogin()" 。

I think you need to call the vallogin() function?

I don't see a submit button in your code, so something like:

<input type="submit" value="Login" onclick="vallogin(); return false" />

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.

枕头说它不想醒 2024-10-26 13:41:40

如果您需要的只是发布表单 @logic-unit 具有

在您的 php 代码上执行页面的正确方法,那么您似乎做得很好,只需确保您确定何时调用
函数

if( isset($_GET['vallogin']) && $_GET['vallogin'] === 1 ){
//execute function here
}

只是确保你不会混淆 GET 和 POST,你似乎正在传递用户、密码数据,这些数据应该位于 php 的 _POST 对象上,或者你甚至可以考虑使用 _REQUEST

if all you need is post the form @logic-unit has the proper way of executing the page

on your php code you seem to be doing things ok, just make sure you identify when to call the
function

if( isset($_GET['vallogin']) && $_GET['vallogin'] === 1 ){
//execute function here
}

just make sure you dont confuse your GET and your POST, you seem to be passing user, password data, which should be on the _POST object of php, or you might even consider using _REQUEST

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文