sdrost Posted November 30, 2012 Share Posted November 30, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/271422-changing-a-link-variable/ Share on other sites More sharing options...
codefossa Posted November 30, 2012 Share Posted November 30, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/271422-changing-a-link-variable/#findComment-1396563 Share on other sites More sharing options...
sdrost Posted December 1, 2012 Author Share Posted December 1, 2012 (edited) 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 December 1, 2012 by sdrost Quote Link to comment https://forums.phpfreaks.com/topic/271422-changing-a-link-variable/#findComment-1396578 Share on other sites More sharing options...
MDCode Posted December 1, 2012 Share Posted December 1, 2012 Php can not change URL content. I'm not even sure that htaccess will work in this case since I'm assuming you want to use the email located in the URL Quote Link to comment https://forums.phpfreaks.com/topic/271422-changing-a-link-variable/#findComment-1396584 Share on other sites More sharing options...
Pikachu2000 Posted December 1, 2012 Share Posted December 1, 2012 There has to be a better solution that what you're attempting. What, exactly are you trying to accomplish? Quote Link to comment https://forums.phpfreaks.com/topic/271422-changing-a-link-variable/#findComment-1396586 Share on other sites More sharing options...
codefossa Posted December 1, 2012 Share Posted December 1, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/271422-changing-a-link-variable/#findComment-1396595 Share on other sites More sharing options...
trq Posted December 1, 2012 Share Posted December 1, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/271422-changing-a-link-variable/#findComment-1396596 Share on other sites More sharing options...
codefossa Posted December 1, 2012 Share Posted December 1, 2012 This would switch between the first email and the second depending on wether ?value=1 or ?value=2 Oh, I misunderstood him. Ignore my posts then. Quote Link to comment https://forums.phpfreaks.com/topic/271422-changing-a-link-variable/#findComment-1396599 Share on other sites More sharing options...
sdrost Posted December 1, 2012 Author Share Posted December 1, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/271422-changing-a-link-variable/#findComment-1396669 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.