<form action="http://www.website.com/add" method="post" target="_blank" >
<select name="productid">
<option value="84215_212">Size S</option>
</select>
<input type="hidden" value="1" name="xQuantity">
<button class="button" type="submit"">
<span>Add to bag</span>
</button>
I would like to set my form above to send the request as "302 Moved Temporarily" instead of "200" after submitting which would then redirect to http://www.website.com/cart with GET request. How do I implement this? Thanks.
Add the following at the top of the script handling /add
:
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// do something, then
header('Location: /cart', true, 302);
exit();
}
?>
I would like to set my form above to send the request as "302 Moved Temporarily" instead of "200"
Note, the code for "Moved Temporarily" is 301, not 302 (which is a code for "Found").