![]() | ![]() | ||||||||
| | #1 |
| TNT Join Date: Sep 2012 Location: florida
Posts: 20
Thanks: 16
Thanked 0 Times in 0 Posts
|
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> |
| | |
| | #2 |
| HyperActive Warrior War Room Member Join Date: Sep 2012 Location: Ohio, USA
Posts: 140
Thanks: 8
Thanked 35 Times in 31 Posts
|
Use ajax to push the data into your own local database, and let the form submit as normal.
|
| | |
| | |
| | #3 |
| Digital Carpenter War Room Member Join Date: Aug 2012 Location: Pennsylvania
Posts: 923
Thanks: 187
Thanked 229 Times in 189 Posts
|
do it with JQUERY $.POST() .. easy.
|
| | |
| | |
| | #4 |
| Active Warrior Join Date: Mar 2012
Posts: 38
Thanks: 0
Thanked 4 Times in 4 Posts
|
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. |
| | |
| | |
| | #5 |
| HyperActive Warrior War Room Member Join Date: Sep 2010 Location: Tokyo
Posts: 299
Thanks: 24
Thanked 40 Times in 39 Posts
|
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. |
| | |
| | |
| | #6 |
| eCommerce + mCommerce War Room Member Join Date: May 2012 Location: NL & Peru & USA
Posts: 345
Blog Entries: 2 Thanks: 25
Thanked 80 Times in 68 Posts
|
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!
|
| Public Beta Relased: 100% Free SRS Easy Android Root software launch. Mainly Samsung but also HTC, ZTE and more. 1-Click Android Root and Unroot! [SOOOON] My new -ALL FREE- Premium eBook website | |
| | |
| | #7 |
| TNT Join Date: Sep 2012 Location: florida
Posts: 20
Thanks: 16
Thanked 0 Times in 0 Posts
| 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."; ?> |
| | |
| | #8 |
| TNT Join Date: Sep 2012 Location: florida
Posts: 20
Thanks: 16
Thanked 0 Times in 0 Posts
|
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."; ?> |
| | |
![]() |
|
| Bookmarks |
| Tags |
| form, locations, multiple, posting |
| Thread Tools | |
| |
![]() |