Form posting to multiple locations

7 replies
Trying to get this form to post to my db with process.php and to another website using POST. Right now it will only load the second f.action. If I remove the first f.submit() it only does the first f.action. Any idea on getting this to work?


<script type="text/javascript">
<!--
function newWin(f)
{

f.target="_blank";
f.action="process.php?mobile_no=";
f.submit()
f.target="_blank";
f.actuon="secondsite"
f.submit();
return true;



}
//-->
</script>



</head>

<body>


<div data-role="page" id="page">


<form method="POST" action="secondsite" onsubmit="newWin(this)">



<div data-role="content">




<center>
<p><input type="text" id="mobile_no" name="mobile_no" placeholder="Phone Number"></p>


</center>
<p><input type="submit" value="Submit"></p>


</div>



</form>


</div>
#form #locations #multiple #posting
  • Profile picture of the author dwoods
    Use ajax to push the data into your own local database, and let the form submit as normal.
    {{ DiscussionBoard.errors[7043379].message }}
  • {{ DiscussionBoard.errors[7044520].message }}
    • Profile picture of the author eswariseo
      By using Ajax, you can do it, just get the mobile_no value using document. getElementById("mobile_no") .value. and using xmlHttp.open("GET",url,true); you can save in your database.
      url will be contains ur file name with path.in that file u can get the value and save it.
      {{ DiscussionBoard.errors[7045709].message }}
    • Profile picture of the author otfromtot
      Originally Posted by FirstSocialApps View Post

      do it with JQUERY $.POST() .. easy.
      would that be like this?
      $.post('process.php', function(data),'site2', function(data) { $('.result').html(data); });
      or
      $.post('process.php','site2' function(mobile_no) { $('.result').html(mobile_no); });
      I'm not too familiar with jquery and have light work with ajax. Thanks for all the replies guys!
      Oh, I forgot in the original post that I was also trying to have "site2" open either in _self or _blank and all I need for process.php is for it to submit

      Or would I be able to add some type of forwarder into process.php?
      <?
      $mobile_no=$_POST['mobile_no'];

      mysql_connect("localhost", "dbuser", "dbpass) or die(mysql_error());
      mysql_select_db("dbname") or die(mysql_error());
      mysql_query("INSERT INTO `data` VALUES ('$mobile_no')");
      Print "Your information has been successfully added to the database.";

      ?>
      {{ DiscussionBoard.errors[7047938].message }}
  • Profile picture of the author ussher
    Its not supposed to be possible to do that.

    with javascript you will find you will have problems posting to/from the www. and non-www. version of the site because javascript considers THAT cross-domain.

    better to re-think your plans.

    Perhaps open a window on the other site with a unique identifier that tells that site that your site has new info for it, then transfer via xml or json the data that you want with the server that its going to reading the information instead of your server sending it.
    Signature

    "Jamroom is a Profile Centric CMS system suitable as a development framework for building entire communities. Highly modular in concept. Suitable for enterprise level development teams or solo freelancers."

    - jamroom.net
    Download Jamroom free: Download
    {{ DiscussionBoard.errors[7045750].message }}
  • Profile picture of the author SteveSRS
    you can use PHP.. when processing the $_POST array just first process it to your own database when you have done that make a CURL post to the other db. You don't even have to leave your url / page!
    {{ DiscussionBoard.errors[7046095].message }}
  • Profile picture of the author otfromtot
    I managed to get it with this in my process.php file. and just had the form submit to it with the GET method.

    <?php
    $phone = $_GET['phone'];
    header("Location: site?=&phone=$phone");
    ?>
    <?
    $phone=$_GET['phone'];

    mysql_connect("localhost", "db_user", "db_pass) or die(mysql_error());
    mysql_select_db("db_name") or die(mysql_error());
    mysql_query("INSERT INTO `data` VALUES ('$phone')");
    Print "Your information has been successfully added to the database.";

    ?>
    {{ DiscussionBoard.errors[7057451].message }}

Trending Topics