发布表单数据到另一个网页,然后再张贴 [英] Posting form data to another page and then Posting it again

查看:127
本文介绍了发布表单数据到另一个网页,然后再张贴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前使用这种code来发布表单数据以 HTTPS ://www.esendex.com/secure/messenger/formpost/SendSMS.aspx

I am currently using this code to POST a form's data to https://www.esendex.com/secure/messenger/formpost/SendSMS.aspx:

<script type="text/javascript">

        $(document).ready(function(){
            $("#textnextofkin").validate({
                debug: false,
                rules: {
                    name: "required",
                    email: {
                        required: true,
                        email: true
                    }
                },
                messages: {
                    name: "Please let us know who you are.",
                    email: "",
                },
                submitHandler: function(form) {
                    // do other stuff for a valid form
                    $.post('http://www.example.co.uk/erc/process2.php', $("#textnextofkin").serialize(), function(data) {
                        $('#results').html(data);
                    });
                }
            });
        });

</script>

    <form name="textnextofkin" id="textnextofkin" method="POST" action="">
        <div class="hiddenfields">
            <p>Username:<br>
                <input name="EsendexUsername" type="text" value="AAAAA"></p>
            <p>Password:<br>
                <input name="EsendexPassword" type="password" value="AAAAA"></p>
            <p>Account:<br>
                <input name="EsendexAccount" type="text" value="AAAAA"></p>
            <p>Send Name<br>
                <input name="EsendexOriginator" type="text" value="example"></p>
            <p>Recipient:<br>
                <input name="EsendexRecipient" type="text" value="01234123456"></p>
            <p>Message:<br>
                <input name="EsendexBody" rows="3" cols="20" value="Hello test message"></p></div>
                <input type="submit" class="email-buttons" name="submit" value="Text next of kin">
    </form>

process2.php:

process2.php:

<?php 
    // Initialise CURL
    $curl_handle = curl_init();
    $data ="EsendexUsername=AAAAA&EsendexPassword=AAAAA&EsendexAccount=AAAAA&EsendexRecipient=01234123456&EsendexBody=test"; 
    $url = "https://www.esendex.com/secure/messenger/formpost/SendSMS.aspx";
    curl_setopt ($curl_handle, CURLOPT_URL,$url);
    curl_setopt ($curl_handle, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt ($curl_handle, CURLOPT_POSTFIELDS, $data);

    $result = curl_exec ($curl_handle);
    curl_close ($curl_handle); 
?>

我需要改变,这样我可以张贴表单数据process.php代替,然后使用process.php将信息发送到Esendex网站。我需要这样做,因为process.php包含的数据,我需要的形式,包括(如$ _SESSION [如first_name'])。我想我需要改变Esendex网址上面process.php,但我不知道该怎么进入process.php页面发送它临危的信息。

I need to alter this so that I can POST the form data to process.php instead, and then use process.php to send the information to the Esendex website. I need to do this because process.php contains data I need to include in the form (e.g. $_SESSION['first_name'] ). I suppose I will need to change the Esendex URL above to process.php, but then I don't know what to enter into the process.php page to send the information it recieves.

可能有人请帮助我做到这一点?

Could someone please help me to do this?

感谢您的帮助

推荐答案

最重要的,你需要知道的是,你需要卷曲启用之前,你可以使用下面的code。卷曲通常是启用的,但它值得检查

The most important you need to know is that you need curl to be enabled, before you can use the code below. Curl is usually enabled, but its worth checking

<?php 
    // Initialise CURL
    $curl_handle = curl_init();
    $data ="EsendexUsername=value&EsendexUsername=value&EsendexAccount=value"; 
    $url = "https://www.esendex.com/secure/messenger/formpost/SendSMS.aspx";
    curl_setopt ($curl_handle, CURLOPT_URL,$url);
    curl_setopt ($curl_handle, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt ($curl_handle, CURLOPT_POSTFIELDS, $data);

    $result = curl_exec ($curl_handle);
    curl_close ($curl_handle); 
?>

修改

试试这个code,而不是

try this code instead

<?php 
    // Initialise CURL
    $curl_handle = curl_init();
    $data ="EsendexUsername=value&EsendexUsername=value&EsendexAccount=value"; 
    $url = "https://www.esendex.com/secure/messenger/formpost/SendSMS.aspx";
    curl_setopt ($curl_handle, CURLOPT_URL,$url);
    curl_setopt ($curl_handle, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt ($curl_handle, CURLOPT_POSTFIELDS, $data);
    curl_setopt( $curl_handle, CURLOPT_SSL_VERIFYPEER, false );  //so we can post to https  
    $result = curl_exec ($curl_handle);
    curl_close ($curl_handle); 
?>

以上code是只是一个片段,所以我没有通过所有的$数据,你所看到的,所以你必须使它更加完善。放置$ C $中的c process.php并且它应该将数据发送到Esendex网站

The above code is just a snippet, so i did not pass all $data as you can see, so you will have to make it more complete. Place the code in process.php and it should send the data to Esendex website.

修改 我建议你​​读上卷曲真正理解什么在code以上回事。一个很好的起点将是 php.ne T位点

EDIT I would advise that you read up on CURL to really understand whats going on in the code above. A good starting point would be the php.net site

这篇关于发布表单数据到另一个网页,然后再张贴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆