I am trying to pass a value with a url which goes to a login page. The login page has a https url and when I follow the link it removes the variable at the end. So for example the url starts off as
https://website.com/login?myvalue
The link works and the url still contains the value when I get to the page but by the time the page has finished loading the value is gone. The url becomes:
https://website.com/login
Is it not possible to pass a value with a https url or am I just doing it wrong?
All help appreciated. Thanks in advance.
Surely you should assign a value to the urlURL variable myvalue?
https://website.com/login?myvalue=yes
I haven't worked with HTTPS, only HTTP, but it should work the same unless they don't allow request variables.
Turned out to be a redirect over-writing the url. I had to use session variables in the end unfortunately
Related
When I call the script using /landing.php?source=param I want the script to do a redirect to a URL on another domain, but I don't want the people on the other domain to see the source=param parameter in their analytics or server logs, I don't mind them being able to see the /landing.php URL.
Any ideas on a solution?
A solution is to redirect to an URL on your server (possibly the same page) that doesnt contain the query string first, and then send the user to your off-site destination. You can pass the needed parameter/url on your server with a $_SESSION or $_POST
/landing.php?source=param > /redirect.php > www.offsite.com
In your landing.php, check for the source variable and then redirect it to landing.php or another page without the GET variable e.g. :
if(!empty($_GET['source'])){
// Save the source into a COOKIE / SESSION
// Then redirect to another page to strip out the GET variable.
redirect('landing.php');
}
Then either in landing.php or another file, just redirect to the offsite URL. You'll have the source in a COOKIE / SESSION to use if you need to do anything else with it.
I want to check redirect to another link from our webpage if user clicking on back from browser I must be alert for user such as 'Backword Forbidden ...'
I'm using this code and that not working for me:
$referer = Request::header('referer');
or how to check witch URL user backword to our site?
If you want to get the Referer URL, you can use either Request::header('referer') or native $_SERVER["HTTP_REFERER"]. But there are (at least) 2 problems with that:
It can be spoofed, empty etc.
It will only work if the person got to your page through a link. It won't work when pressing the browser's back button or backspace.
The function you're looking for is Request::server() which functions just like the $_SERVER super global, so to get the page referer you'd do the following.
$referer = Request::server('HTTP_REFERER');
Using Request::header('refer') will only work for POST requests.
GET requests are the one your're looking for.
You can use Request::segment(1) or Request::segment(2), depends on the exact URL you're using.
I m in a situation where i am redirecting user to another page with following jQuery code
window.location = "/#/customer/email?isEmail=true&eid=1&template=2";
i have some url re-writing , and so complete url becomes is
https://demo.qa.com/#/customer/email?isEmail=true&eid=1&template=2
but in PHP when i try to get full page url using this
echo $_SERVER['REQUEST_URI'];
it just gives me this
/
i just want to get variable IsEmail
$_GET['IsEmail']
value in PHP page,
I think the
#
in between the URL is creating the problem, is there any way to get it, please advise..
The fragment is never sent to the server, so if you want access to the query parameters you need to bring them forward:
https://demo.qa.com/?isEmail=true&eid=1&template=2#/customer/email
^ ^
query fragment
The anchor fragment portion of the URL (anything after #) isn't sent to the server at all. It only lives client-side. The server has no knowledge of it, and therefore PHP has no knowledge of it.
If you want to do anything with the anchor fragment, you must do it client-side.
I want to get original URL (user entered URL) from 301 redirected URL.
Ex:
www.mydomain.com/about-1/
www.mydomain.com/about-2/
www.mydomain.com/about-3/
All above URLs want to redirect www.mydomain.com/about/. So I did it using simple .htaccess redirect. My problem is how to find from where user came (which original URL).
I've tried $_SERVER['HTTP_REFERER'] but it didn't work.
Passing variable like www.mydomain.com/about-1/?val=1 may a easy solution but it is not possible in this situation.
the HTTP_REFERER in _SERVER tells you where it is from. What I do sometimes is append a parameter to the url (either with a script.php?param=source or with a path script.php/path) to help me make the processing easier. These parameters can be added transparently to the script with an htaccess rule)
The easy way to do this is to take the url of the referrer to www.mydomain.com/about/ URL as a variable.
<?php header("Location: http://www.mydomain.com/about?referrer=http://www.mydomain.com/about-1" ,TRUE,301); ?>
Then you always have the referrer with the $_GET variable.
You can do it using PHP. Here is the link to get code to do it.
http://www.phpjunkyard.com/tutorials/php-redirect.php
I'm using a form to submit some post information to a PHP script. After the script finishes, I want it to redirect right back to the page the user came from. Right now I'm just using header() with a static URL. I've found a ton of very conflicting information about this around the internet, so I'm wondering what StackOverflow thinks.
Use HTTP_REFERER:
header('Location: ' . $_SERVER['HTTP_REFERER']);
access the $_SERVER['HTTP_REFERER'] variable and redirect to this. Should do the trick.
the way i would do it is use a session variable to store the current page URL everytime it is accessed.
$_SESSION['last_url'] = <get current url>
replace your static url in the header with $_SESSION['last_url']. Depending on how you implement your PHP, you can use search google for "current url php" or just $_SERVER['REQUEST_URI'] (stackoverflow doesnt allow me to put more than 1 link!)
Use REQUEST_URI But watch out for that presiding slash/