2

I have a strange issue where I have the following form/php form handler:

 <form id="search" method="get" action="page.php?pg=xxxxxx">

On submit, in the url I get domain.com/page.pgp?action=xxxx....(more get parameters here). How can I pass the pg=xxxx into the action url correctly? I tried throwing an & sign (page.php?pg=xxxxxx&) but that didn't seem to work either.

asked Apr 21, 2016 at 20:24

2 Answers 2

1

You are passing the pg value of "xxxxxx" incorrectly. These values should be passed in the input tags inside the form, for instance:

<form id="search" method="get" action="page.php>
 <input type="hidden" name="pg" value="xxxxxx">
 <input name="submit" value="Submit">
</form>

the previous code creates a form with a button called "Submit", and when you press it, it takes you to your page action.php with the query string you wanted in the url:

http://www.foo.com/action.php?pg=xxxxxx

Hope that helps! :)

answered Apr 21, 2016 at 20:35
Sign up to request clarification or add additional context in comments.

4 Comments

How's your answer different from mine?
@j08691 I explained what he was doing correctly. Your answer is correct, though I thought I should give an explanation of what he was doing wrong. He has a fundamental misunderstanding of how forms pass the "get" information in the query string. Also he should be taking out the pg=xxxxxx from his previous code inside the form tag element.
@Webeng Thank you so much! That worked perfectly. And thank you for the explanation, I haven't used too many get forms yet. Appreciate it!
@Jazzerlol glad I could help! If this answer is the one that worked for you, please accept the answer by clicking the check mark on the left of the answer so that future users know that it is what worked for you :)
0

Add a hidden input to your form instead:

<input type="hidden" name="pg" value="xxxxxx" />
answered Apr 21, 2016 at 20:26

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.