在两个php脚本上发帖。

时间:2015-07-13 13:40:04

标签: javascript php database post

我正在尝试将表单的值发布到两个数据库。 其中一个是本地的,一个不是。这就像是客户的“备份”。

我现在的问题是我必须使用“POST”方法并将值传递给两个不同的脚本。我不知道我怎么能这样做。我的服务器不支持curl

这就是我正在使用的:

<form action="" method="post" enctype="multipart/form-data" id="form">
<table cellspacing='0' onkeydown='return editingKeydown(event);'>
<tr><th>first_name<td class='function'>*<td><input value='' maxlength='100' size='40' id='first_name' name='first_name'>
<tr><th>last_name<td class='function'>*<td><input value='' maxlength='100' size='40' id='last_name' name='last_name'>
<tr><th>company<td class='function'>*<td><input value='' maxlength='100' size='40' id='company' name='company'>
<tr><th>phone<td class='function'>*<td><input value='' maxlength='100' size='40' id='phone' name='phone'>
<tr><th>email<td class='function'>*<td><input value='' maxlength='100' size='40' id='email' name='email'>
<tr><th>zip<td class='function'>*<td><input value='' maxlength='100' size='40' id='zip' name='zip'>
<tr><th>street<td class='function'>*<td><input value='' maxlength='100' size='40' id='street' name='street'>
<tr><th>city<td class='function'>*<td><input value='' maxlength='100' size='40' id='city' name='city'>
<tr><th>state<td class='function'>*<td><input value='' maxlength='100' size='40' id='state' name='state'>
<tr><th>country<td class='function'>*<td><input value='' maxlength='100' size='40' id='country' name='country'>
<tr><th>reasons<td class='function'>*<td><input value='' maxlength='300' size='40' id='reasons' name='reasons'>
<tr><th>notes<td class='function'>*<td><input value='' maxlength='300' size='40' name='notes' id='notes'>
<tr><th>callback<td class='function'>*<td><input value='' maxlength='100' size='40' id='callback' name='callback'>
</table>
<p>
<input type='submit' value='Salvează' onclick='javascript: return SubmitForm()'>


</form>

<script type='text/javascript'>

function SubmitForm()
{
    if(document.forms['form'].onsubmit())
    {
        document.forms['form'].action='http://www.example.com/script1.php';
        document.forms['form'].submit();

        document.forms['form'].action='preproc.php';
        document.forms['form'].submit();
    }
    return true;
}



</script>

这对我不起作用。你知道我能做到这一点吗?甚至替代品......

感谢您的回答。

1 个答案:

答案 0 :(得分:0)

尝试使用public static TypeThing buildMyThing(TypeA a, TypeB b, TypeC c) { if (c.getData() == null) throw new IllegalArgumentException(""); return new TypeThing(a, b, c.getOtherData()); } public Constructor(TypeA a, TypeB b, TypeD d) { // stuff happens } https://api.jquery.com/category/deferred-object/

这样您的请求将同时发送,速度更快:

jQuery.Deferred();