1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Form Submit issue

Discussion in 'HTML & Website Design' started by ott, Sep 26, 2012.

  1. #1
    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?
    I'm also trying to have "site2" open either in _self or _blank, with the information passed on to it, and all I need for process.php is for it to submit


    <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>


    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 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.";

    ?>
     
    ott, Sep 26, 2012 IP
  2. ott

    ott Greenhorn

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #2
    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: http://www.site.com/?a=1k4wlay&b=1pl2isa&s1=&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.";

    ?>
     
    ott, Sep 26, 2012 IP
  3. tkcoding

    tkcoding Peon

    Messages:
    23
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    If you want fire two post request in one submit i think you will need ajax request instead of normal request
     
    tkcoding, Sep 29, 2012 IP
    ott likes this.
  4. WeddiGo

    WeddiGo Greenhorn

    Messages:
    40
    Likes Received:
    2
    Best Answers:
    2
    Trophy Points:
    18
    #4
    you have to use ajax for multiple posts
     
    WeddiGo, Sep 30, 2012 IP
    ott likes this.
  5. ott

    ott Greenhorn

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #5
    thanks guys, but i got it to work with the previous pos
     
    ott, Oct 1, 2012 IP