Search code examples
phpjavascriptformscurlfill

Fill in an external form using cURL?


Can anyone suggest how I could fill in this form with my own variables and submit it using cURL/PHP? Is it possible, as it seems to use JavaScipt instead of the normal 'post' to submit the content. Thanks for the help.


Solution

  • It is done via javascript. It submits a post request for each checkbox on the page

    These are the functions you need to replicate:

    function ActionSubmit(){
        var Posturl="/modules/";
        var url=$("#url").val();
        var title=$("#title").val();
        var WebSite=$("#WebSite").val();
        var email=$("#email").val();
        var description=$("#description").val();
        var data='url='+url+"&title="+title+"&WebSite="+WebSite+"&email="+email+"&description="+description;
        var str="";
        if (formVaildate()){
             $("[name='checkbox'][checked]").each(function(){
                 str=$(this).val();
                 strs=str.toLowerCase()
                 strs=strs.replace("-","_");
                 Posturl= Posturl+strs+"/"+strs+".php";
                 URLSubmit(Posturl,data,str);
                 Posturl="/modules/";
           });
        }
    }
    function URLSubmit(url,data,str){   
        $.ajax({
                url: url,
                type: 'POST',
                data: data,
                beforeSend:function(){
                        $("#"+str+"_State").html("Please wait...");
                    },
                complete:function(){
                        $("#"+str+"_State").html("<img src='/images/right.gif'>");
                    },
                success:function(msg){
                   if (msg!=""){            
                    $("#"+str+"_State").html("<img src='/images/right.gif'>");
                   }else{
                       alert(msg);
                   }
                  }
            });
    
    }