1

I want to hide get variables in url

I want this

"dem/?p=user"

instead of whatever i passed like

dem/?p=user&act=stored
dem/?p=user&act=changed
dem/?p=user&act=deleted

Mates please help for me. Advance thanks.

White Marcus
  • 195
  • 2
  • 3
  • 12

4 Answers4

5

If you want to hide GET variables or values you should not use GET. In GET methods the data will always be send as part of the url. If you want to 'hide' the data (or not show it in the URL) from the user you should use a POST method.

ianaya89
  • 4,153
  • 3
  • 26
  • 34
  • dude, after changes (insert, delete, upload), i want to reload page. thats why the changes are reflected in the page. so i am using (window.location.href= "?p=user&act=deleted"). so finally how to i pass variable in post method using window.location function. – White Marcus Nov 20 '14 at 06:52
2

You may use any one of the following:

  • Use POST method instead of GET
  • Use Ajax, with either POST or GET method
  • Use encryption and decryption if you really wish to send secured way i.e dem/?p=ENCRYPTED_STRING. Here ENCRYPTED_STRING will have all the GET data
Ashique C M
  • 733
  • 4
  • 8
  • dude, after changes (insert, delete, upload), i want to reload page. thats why the changes are reflected in the page. so i am using (window.location.href= "?p=user&act=deleted"). so finally how to i pass variable in post method using window.location function. – White Marcus Nov 20 '14 at 06:53
  • here y u wanna pass this with URL?, just reload and show the messages that the "User has been deleted",inserted etc. You can use simply POST method. Other wise better way to handle this case is Ajax. another method create different pages for insert, delete, listing functionality. – Ashique C M Nov 20 '14 at 07:16
  • i already performed Ajax and POSt method, after deletion i receive delete msg, but below table also shows the deleted user. once i manually reload the page, then only that user vanished. Final thing is perform (del,ins,upd) after i want to get msg (without using alert) and also the updated table records (users). – White Marcus Nov 20 '14 at 10:38
  • Encryprion is a great idea. The password can be on the server, not visible at all to the client – Andrey Rubshtein Aug 05 '21 at 06:48
2

Obviously since you did not take the time to tell us how you page structure is and how you are storing your values I can only guess.

Server side

If you store the data on a post-redirect page you can store it in a $_SESSION

session_start();
if (isset($_SESSION['message']))
{
    $_SESSION['message'] = "succes";
}

Then on your confirmation page

session_start();
echo $_SESSION['message'];

Client side

You can create hidden inputs and add these to your form, set your form to post and handle these $_POST values on your form action page.

var x = document.createElement("INPUT");
x.setAttribute("type", "hidden");
x.setAttribute("name", "message");
form.appendChild(x);

Then on your confirmation page

if (isset($_POST['message']))
{
    echo $_POST['message'];
}
Seunhaab
  • 550
  • 4
  • 6
-1

modify .htaccess file to make short URLs the way you want them to look like

Katyoshah
  • 129
  • 10
  • i know about htaccess. but i dont have enough knowledge to write a htaccess. please give a code or help how to write........ thanks. – White Marcus Nov 20 '14 at 06:55