abdulkrm

Redirect gla

Apr 5th, 2024
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. if (isset($_GET['add-to-cart'])) {
  2. $addToCartValue = $_GET['add-to-cart'];
  3. // Check if the value starts with 'gla_'
  4. if (strpos($addToCartValue, 'gla_') === 0) {
  5. // Extract the numeric part after 'gla_'
  6. $numericId = substr($addToCartValue, 4);
  7. // Validate that the remaining string is numeric
  8. if (ctype_digit($numericId)) {
  9. // Redirect to the same page with the corrected query string
  10. $newUrl = '/gallery/?add-to-cart=' . $numericId;
  11. header('Location: ' . $newUrl);
  12. exit; // Stop further execution of the script
  13. }
  14. }
  15. }
  16.  
Advertisement
Add Comment
Please, Sign In to add comment