Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7403807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:09:48+00:00 2026-05-29T05:09:48+00:00

As a continuation of Adding Values to a Query String in a URL ,

  • 0

As a continuation of Adding Values to a Query String in a URL, I have a search box that will add additional arguments to the current URL.

http://example.com/?s=original+new+arguments&fq=category

The form code looks like this:

<form id="FilterSearch" method="get" action="http://example.com/search_result.php">

Where search_result.php is just a new page I created to parse the submit and redirect using the new URL.

How can I pass the original URL to search_result.php so that I can then manipulate the URL?

EDIT #1 : I added a hidden input:

<?php $current_url = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]; ?>
<input type="hidden" name="current_url" value="<?php $current_url; ?>" />
<input name="send" id="send" type="submit" value="Search" />

My output is only adding the arguments to the submission page (search_result.php) and not the intended query page.

<?php
if (isset($_GET['send'])){
                $searchField = urlencode($_GET['SearchField']);
                $location =  $_GET['current_url'];
                $location = preg_replace($location, '/([?&]s=)([^&]+)/', '$1$2+'.$searchField);
                header('Location: '.$location);
                }
?>

I’m either passing them wrong or getting them wrong or both!

EDIT #2 : Output URL is like:

http://example.com/wp-content/themes/child_theme/search_result.php?SearchField=newTerm&current_url=www.example.com%2F%3Fs%3DoldTerm%26searchsubmit%3D&send=Search

EDIT #3
I echoed the output URL and it’s correct. I got rid of the preg_match just to see if I could get the same URL when I processed the form. Interestingly, I got a page not found. I decided to add http:// the header and it worked:

header('Location: http://'.$location);

So therefore, I believe that the only thing wrong here is the preg_replace.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:09:49+00:00Added an answer on May 29, 2026 at 5:09 am

    I think you’re looking for the hidden input.

    Something like this:

    <input type="hidden" name="current_url" value="(Current URL here)" />
    

    Then access it just like you would any other $_GET or $_POST parameter.


    EDIT to respond to edits:

    Could you echo $location; die; after this line:

    $location =  $_GET['current_url'];
    

    and let me know what the output is? This will tell us whether it’s being passed incorrectly or processed incorrectly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In continuation with my pay pal questions... I have been able to add the
This is a continuation question from a previous question I have asked I now
This is a continuation of the question here: JBoss - does app have to
This post is the continuation of my previous post . Now I have a
This is in continuation of jqgrid - json looping issue with the difference that
In continuation of the question at this link I wanted to add some functionality
This post is an continuation of this post I have DlUser Class each object
This is a continuation of the question Java rounded Swing JButton . I have
This question is in continuation of this post , I have tried installing Xerces-C
This is my continuation of my work: Adding DateTime in C# I already can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.