how to hide the variables values shown in the url which is done in php,javascript

I have a form written in php,html,javascript I pass the value using the javascript href .location and the values can be seen in the url by the user  I want to hide this
leenapedenekarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sandeshjCommented:
Instead of using href.location, create a <form/> with method="post" and action="...the page where you want to go to....", inside the form have the parameters you want using  tag and submit this action on click using javascript.
0
Mehul_PanchalCommented:
you have to pass parrameter in post hidden variable so that it not shown in url.



Thanks
Mehul
0
StealthyDevCommented:
Yes, they are correct. I would like to give an example for you:

FInd it:
<form name="myhiddenform" method="post">
<input type="hidden" name="param1" id="param1">
</form>

<input type="button" onclick="submitForm()" value="submit">

<script>
	function submitForm()
	{
		//window.location = "mypage.php?param1=xyz";
		document.getElementById("param1").value="xyz";
		document.myhiddenform.action = "mypage.php";
		document.myhiddenform.submit();
	}
</script>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

leenapedenekarAuthor Commented:
Some of the data which I take from the user depends upon the selection of the data prior to the some inout boxes eg.batchno select box to be shonly when proudct code is selected and the for the query also the batchno selection query will depend upon the product code selected then in thatb case how do I do it without passing it in the url
0
StealthyDevCommented:
You can have multiple hidden fields in the form.

See example:


<form name="myhiddenform" method="post">
<input type="hidden" name="param1" id="param1">
<input type="hidden" name="batchno" id="batchno">
<input type="hidden" name="proudctcode" id="proudctcode">
</form>

<input type="button" onclick="submitForm()" value="submit">

<script>
	function submitForm()
	{
		//window.location = "mypage.php?param1=xyz";
		document.getElementById("param1").value="xyz";
		document.getElementById("batchno").value="abc";
		document.getElementById("proudctcode").value="123";
		document.myhiddenform.action = "mypage.php";
		document.myhiddenform.submit();
	}
</script>

Open in new window

0
leenapedenekarAuthor Commented:
Will try n see if this fits my requirement and get back
0
leenapedenekarAuthor Commented:
sorry for late reply but was cuaght up with something else

But if the value in the second select box depends upon the first input box i.e the first input box value entered is used to query the table on the database server then how do i get it
0
dejaanbuCommented:
I dont know your actual Objective, but what is the need for posting values using javascript?

If you are using the <form> tag with POST method. Then nothing to worry. Every HTML Control with an ID specified will be automatically posted the specified target php file.
check
<form name="YourForm" method="post" action="THEDESTINATIONFILE.php">

in THEDESTINATIONFILE.PHP , simply put
if(isset($_POST)){
echo '<pre>';
print_r($_POST);
echo '</pre>';
}
0
TocacarCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.