Workaround possible for cURL and Javascript?

Go To StackoverFlow.com

0

Everything was going great in my previous help request thread. I was on the correct track to get around a CSRF, but needed to be pointed in the right direction. I received great help and even an alternate script used to log into Google's Android Market. Both my script and the one I altered to match my form is get hung up at the same point. Apparently cURL cannot process JS, is there any way to work around the form being submitted with submitForm() without changing the form?

Here is the code for the SubmitForm function

function submitForm(formObj, formMode) {
    if (!formObj)
        return false;
    if (formObj.tagName != "FORM") {
        if (!formObj.form)
            return false;
        formObj = formObj.form;
    }
    if (formObj.mode)
        formObj.mode.value = formMode;
    formObj.submit();
}

Here is the code for the submit button -

<a class="VertMenuItems" href="javascript: document.authform.submit();">Submit</a>

Here is a link to my last question in case more background information is needed.

2012-04-03 20:45
by Eric
Would submitting data from javascript to PHP suffice? If so, I can provide some psuedo code for using Javascript to pass information to a PHP service - NoName 2012-04-03 22:01
@syn4k Thank you for getting back to me I believe this might work, can you show me how you would go about doing this - Eric 2012-04-04 15:42


1

PHP service...

<?php
// PHP service file

// Get all data coming in via GET or POST
$vars = $_GET + $_POST;

// Do something with the data coming in
?>

Javascript elsewhere...

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        function sendData(data)
        {
            var response;
            $.ajax({
                url: 'phpservice.php',
                data: data,
                type: 'POST',
                dataType: 'json',
                async: false,
                success: function(response_from_service)
                {
                    response = response_from_service;
                },
                error: function()
                {
                }
            });
            return response;
        };
        function getData(data)
        {
            var response;
            $.ajax({
                url: 'phpservice.php',
                data: data,
                type: 'GET',
                dataType: 'json',
                async: false,
                success: function(response_from_service)
                {
                    response = response_from_service;
                },
                error: function()
                {
                }
            });
            return response;
        };
    });
</script>
2012-04-04 20:39
by NoName
Excellent, thank you so much for your assistance. My only question is where do I put this? I would assume onto the page that I am using the login, but is it possible to simply put this in the file running cURL? Thank you again for your help - Eric 2012-04-05 15:01
You're welcome! You could possibly merge the PHP code into your cURL script since they are both PHP but my suggestion would be against this. Mostly to avoid confusion. I would suspect that it's really a matter of preference. The javascript should go onto the page that the form exists. I would suggest creating a new javascript include in the head of that document so that you don't have a mess later on - NoName 2012-04-05 18:49
Awesome Syn. Thank you so very much for being an enormous help. I never would have been able write that script you provided me with - Eric 2012-04-05 19:11
Ads