0

My users arrive on the page, optionally with a query string.

The query string data - if present - goes into a textarea element in a form, where it may be edited, then POSTed back to the page with the submit button.

Now I have a bit of a mess because the query string, which was ignored when the the form posted data, is showing obsolete information.

i.e. the user arrives with ?fruit=apple, changes apple to pear in the form, submits the form, now the form says pear, (and I've goe my pear products listed below, which is the point of the page) but the query string still says ?fruit=apple.

That seems harmless, but it's messy and may confuse the user.

So what I want is to clear the query string from the URL whenever the form is posted.

Clear as mud?

I hope someone can offer a suggestion, I'm stumped.

Edited by scaiferw

2
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by scaiferw
0

What has the action attribute of your form been set to? If form posts to the same page (#) then set the action to the page name without the querystring, something like:

$action = parse_url(__FILE__, PHP_URL_PATH);
echo "<form action='$action'>";
...
0

Dang, just answered my own question.

<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">

Headslap.

0

Thanks broj1, you must have been posting just as I was slapping my head.

Doh!

0

This page dates way back and I was modifying it. It had some pretty bad syntax from my early days in PHP that somehow hadn't been breaking the page until my new code was put in. Jumped up and bit me!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.