Jump to content

Recommended Posts

I am trying to NOT show an email address in my URL. I can pass the variable no problem but I am not sure of the method after that.

 

Here is my example links:

 

www.mywebsite.com/index.php?=email1

www.mywebsite.com/index.php?=email2

 

How would I go about changing these based off the variable in the link?

 

email1 = email@mywebsite.com

email2 = differentemail@mywebsite.com

 

On page 2 I am using:

 

$file_name = $_GET['email1'];

 

I am not sure of the proper term(s) to use to search Google so I am coming to the pros.

 

Thank you in advance,

 

Scott

Link to comment
https://forums.phpfreaks.com/topic/271422-changing-a-link-variable/
Share on other sites

You can encode it or use $_POST instead, but people can still view it since you're passing the raw text. Base64 would be the usual encoding, which is extremely easy to see and know what it is to anyone with any knowledge of it.

 

If you are using this in PHP rather than JS, you could store it in a session.

If you're doing it in JS, maybe Ajax could be your solution?

 

It depends what you're actually doing. If it comes client-side though, unless you have custom encryption in PHP, it's gonna be noticeable. If the email comes from PHP and you want to use it in PHP again, use a session and they'll never see it. If the user puts it in or selects one, etc. then you can't completely hide it.

You can encode it or use $_POST instead, but people can still view it since you're passing the raw text. Base64 would be the usual encoding, which is extremely easy to see and know what it is to anyone with any knowledge of it.

 

If you are using this in PHP rather than JS, you could store it in a session.

If you're doing it in JS, maybe Ajax could be your solution?

 

It depends what you're actually doing. If it comes client-side though, unless you have custom encryption in PHP, it's gonna be noticeable. If the email comes from PHP and you want to use it in PHP again, use a session and they'll never see it. If the user puts it in or selects one, etc. then you can't completely hide it.

 

I am using php. I am really just trying to hide it from the URL in the browser address bar from the average user.

Edited by sdrost

I am using php. I am really just trying to hide it from the URL in the browser address bar from the average user.

If you use $_POST instead of $_GET, the average user wont see it. You could on top of that encode it which will block a few extra people. Just decode it on the page and use it like normal.

I assume your just looking for something like:

 

<?php

if (isset($_GET['value'])) {
 if ($_GET['value'] == 1) {
   $email = 'someemail@somedomain.com';
 } elseif ($_GET['value'] == 2) {
   $email = 'someotheremail@someotherdomain.com';
 }
}
?>

 

This would switch between the first email and the second depending on wether ?value=1 or ?value=2

I assume your just looking for something like:

 

<?php

if (isset($_GET['value'])) {
 if ($_GET['value'] == 1) {
   $email = 'someemail@somedomain.com';
 } elseif ($_GET['value'] == 2) {
   $email = 'someotheremail@someotherdomain.com';
 }
}
?>

 

This would switch between the first email and the second depending on wether ?value=1 or ?value=2

 

This is it! Thank you trq and everyone else for your input.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.