Submit Two Forms w/ One Button??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • superdevo
    New Member
    • Apr 2007
    • 8

    #1

    Submit Two Forms w/ One Button??

    Hey guys,

    I have a php question. I have a php eccommerce site I am working on and have a particular problem.

    Currently when a user presses one of my "Add To Kart" buttons it will add a product to the users cart without changing the current URL, which at that point would be something like "http:www.mydoma in.com/index.php?mod=p roduct&id_prd=5"

    I have a shared SSL certificate on my server and want to redirect the user to a secure URL after they press the "Add To Kart" button, but before the product is submitted to the shopping cart; and in that order (but both after the same "Add To Kart" button is pushed). The secure redirect form displays the same unsecure URL: "http:www.mydoma in.com/index.php?mod=p roduct&id_prd=5" in the following secure manner: "https://servername.host .com/~username/mydomain/html/index.php?mod=p roduct&id_prd=5"

    The product is added to the cart by the following "Add To Cart" form:

    <form name="choosePro perties" method="post" action="<?php
    $KT_Temp = new AddToKartRegist er();
    $KT_Temp->registerField( 'id', $row_rsPrd['id_prd']);
    $KT_Temp->registerField( 'name', $row_rsPrd['name_prd']);
    $KT_Temp->registerField( 'price', $row_rsPrd['price_prd']);
    $KT_Temp->registerField( 'quantity', 1);
    $KT_Temp->registerField( 'weight', $row_rsPrd['weight_prd']);
    echo $KT_Temp->getAddToKartLi nk('MXKart/addToKart.php') ?>">
    <input name="AddToCart " type="submit" class="orangeBu tton" id="AddToCart" value="Add To Cart">


    My "redirect" form has the following code:

    <form name="redirect" method="post" action="<?php echo 'https://servername.host .com/~username/mydomain/html/index.php?'.$_S ERVER['QUERY_STRING']; ?>">
    <label>
    <input type="submit" name="Submit" value="Submit">


    What I would like to know is if there is some way to submit the "redirect" FIRST and then submit the "Add To Kart" form second, after the user hits the "Add To Kart" button?

    Specifically is there any way to do this by calling functions and different pages in PHP without the use of Javascript? If not, what is the most efficient way to do this with the least amount of client side scripting as possible?

    Any and all suggestions or help will be greatly appreciated.

    Thanks
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    First suggestion is to read the Posting Guidelines and enclose your code within code or php tags.

    moderator

    Comment

    • superdevo
      New Member
      • Apr 2007
      • 8

      #3
      Hey guys,

      I have a php question. I have a php eccommerce site I am working on and have a particular problem.

      Currently when a user presses one of my "Add To Kart" buttons it will add a product to the users cart without changing the current URL, which at that point would be something like "http:www.mydoma in.com/index.php?mod=p roduct&id_prd=5"

      I have a shared SSL certificate on my server and want to redirect the user to a secure URL after they press the "Add To Kart" button, but before the product is submitted to the shopping cart; and in that order (but both after the same "Add To Kart" button is pushed). The secure redirect form displays the same unsecure URL: "http:www.mydoma in.com/index.php?mod=p roduct&id_prd=5" in the following secure manner: "https://servername.host .com/~username/mydomain/html/index.php?mod=p roduct&id_prd=5"

      The product is added to the cart by the following "Add To Cart" form:

      Code:
      <form name="chooseProperties" method="post" action="<?php 
      $KT_Temp = new AddToKartRegister();
      $KT_Temp->registerField('id', $row_rsPrd['id_prd']);
      $KT_Temp->registerField('name', $row_rsPrd['name_prd']);
      $KT_Temp->registerField('price', $row_rsPrd['price_prd']);
      $KT_Temp->registerField('quantity', 1);
      $KT_Temp->registerField('weight', $row_rsPrd['weight_prd']);
      echo $KT_Temp->getAddToKartLink('MXKart/addToKart.php') ?>">
      <input name="AddToCart" type="submit" class="orangeButton" id="AddToCart" value="Add To Cart">
      My "redirect" form has the following code:

      Code:
      <form name="redirect" method="post" action="<?php echo 'https://servername.host.com/~username/mydomain/html/index.php?'.$_SERVER['QUERY_STRING']; ?>">
         <label>
           <input type="submit" name="Submit" value="Submit">
      What I would like to know is if there is some way to submit the "redirect" FIRST and then submit the "Add To Kart" form second, after the user hits the "Add To Kart" button?

      Specifically is there any way to do this by calling functions and different pages in PHP without the use of Javascript? If not, what is the most efficient way to do this with the least amount of client side scripting as possible?

      Any and all suggestions or help will be greatly appreciated.

      Thanks

      Comment

      • superdevo
        New Member
        • Apr 2007
        • 8

        #4
        Originally posted by ronverdonk
        First suggestion is to read the Posting Guidelines and enclose your code within code or php tags.

        moderator
        Sorry about that........I just added the code tags.........wi ll my post still be seen by other people, or do I need to repost it????

        Comment

        • ronverdonk
          Recognized Expert Specialist
          • Jul 2006
          • 4259

          #5
          It is okay like this.

          moderator

          Comment

          • Motoma
            Recognized Expert Specialist
            • Jan 2007
            • 3236

            #6
            Create a Javascript onLoad function to perform the second submit.

            Comment

            Working...