• Resolved Fahim Mahmood

    (@urbloodismywine)


    I’m facing a problem i have following form with just a Submit button on a Template Page of WordPress blog:

    <form action="<?php echo get_permalink(); ?>&pid=[page_id]&action=add" method="get">
    <input type="submit" value="Add to Cart" />
    
                              </form>

    on a Template Page i want to submit it to the same page with some values through the URL but reason whenever i submit it it sends me back to homepage i.e. index.php of the template.

Viewing 3 replies - 1 through 3 (of 3 total)
  • 1. Make the form method as post
    2. Remove the parameters from action
    3. Pass the parameters through hidden fields

    Check below code :

    if(issset($_POST['save_data'])){
    // Do operations here...
    }
    
    <form name="frm_add_cart" action="<?php echo get_permalink(); ?> method="post">
    <input type="hidden" name="pid" value = "[page_id]" />
    <input type="hidden" name="action" value = "add" />
    <input type="submit" name="save_data" value="Add to Cart" />
    </form>
    Thread Starter Fahim Mahmood

    (@urbloodismywine)

    Sandip thanks for the reply Its working now :D!!

    Thread Starter Fahim Mahmood

    (@urbloodismywine)

    This is resolved now ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Submitting a form to itself’ is closed to new replies.