[resolved] Submitting a form to itself (4 posts)

  1. Fahim Mahmood
    Posted 3 years ago #

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

    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.

  2. Sandip Patil
    Posted 3 years ago #

    1. Make the form method as post
    2. Remove the parameters from action
    3. Pass the parameters through hidden fields

    Check below code :

    // 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" />
  3. Fahim Mahmood
    Posted 3 years ago #

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

  4. Fahim Mahmood
    Posted 3 years ago #

    This is resolved now :)

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.