简体   繁体   中英

Is it possible to redirect back after form submit done in php?

I have this form:

<form action="/productcategories/foods/" method="GET">
    <input type="hidden" name="add-to-cart" value="<?php echo htmlspecialchars($getid); ?>" />
    <input type="number" name="quantity" min="1" value="1">
    <br><input type="submit" value="Buy" />
</form>

If I hit submit it'll redirect me to a Wordpress plugin generated page, does the add-to-cart action but after I done this form I want to redirect back the user to the current page. Is there any method to do it from the page where the form stored? Like JavaScript or something like that?

You can submit the form and open the redirection in tag, not leaving your site. Then possibly using javascript you can remove on variety of ways, clicking on button or after it will fully load.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM