To show a parameterless URL

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

To show a parameterless URL

Post by anjanesh »

I got a HTML file which contains a form that contains a textbox txtName and a input button butSearch and action is Query.php
When I click the button it goes to
http://localhost/Query.php?txtName=anj&butSearch=Search
Everything is fine - I just dont want the parameters shown in the url. I want this to be seen in the address bar :
http://localhost/Query.php
I tried using hidden fields but hidden fields also get shown in the url.
I have seen this happen during registration etc - the url contains the php file but not the parameters.
Is there a way to do this ?
Thanks
Straterra
Forum Regular
Posts: 527
Joined: Mon Nov 24, 2003 8:46 am
Location: Indianapolis, Indiana
Contact:

Post by Straterra »

Are you using Post or Get? From the sounds of it, your using Get. Try Post.
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Not mentioned GET nor POST

Post by anjanesh »

But I have not mentioned neither GET nor POST : Just this :

Code: Select all

<FORM ACTION="Query.php">
Name :
<INPUT name=txtName title="Searches for any keyword in the name">
<INPUT type="Submit" value="Search" name=butSearch>
</FORM>
Thanks
Straterra
Forum Regular
Posts: 527
Joined: Mon Nov 24, 2003 8:46 am
Location: Indianapolis, Indiana
Contact:

Re: Not mentioned GET nor POST

Post by Straterra »

anjanesh wrote:But I have not mentioned neither GET nor POST : Just this :

Code: Select all

<FORM ACTION="Query.php">
Name :
<INPUT name=txtName title="Searches for any keyword in the name">
<INPUT type="Submit" value="Search" name=butSearch>
</FORM>
Thanks
Try this code.

Code: Select all

<FORM ACTION="Query.php" METHOD="post">
Name :
<INPUT name=txtName title="Searches for any keyword in the name">
<INPUT type="Submit" value="Search" name=butSearch>
</FORM>
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Yes thanks I tried this and worked sucessfully. Now I have another problem in this code. If I click the Search button it'll work but if I hit enter in the textbox after typing some text the quesry sent is (this one without the method=post to know what is being sent):
http://localhost/Query.php?txtName=anj
and not
http://localhost/Query.php?txtName=anj& ... rch=Search
The name SubmitBasicSearch is not being sent when we hit the enter key. I wrote a javascript method for onkeypress for that textbox and determine if the keyCode is 13 - if so then send the correct url but that doesn't happen.
Also Straterra : You told to include POST - I tried GET too. It worked as well so whats the difference b/w POST & GET here ?
Anyone ?
Thanks
Straterra
Forum Regular
Posts: 527
Joined: Mon Nov 24, 2003 8:46 am
Location: Indianapolis, Indiana
Contact:

Post by Straterra »

Get shows the stuff being submitted in the adress bar. Get is good for high data. Post hides the stuff and looks better, but tends to be a bit slower...I'm not very good with Javascript..but can you concantinate txtname=anj with &SubmitBasicSearch= with Search...
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

also: get can be bookmarked, post can't


on top of that, default is get, therefore unless you mention post, html wiill ALWAYS use get
Post Reply