简体   繁体   中英

Detect redirection of remote url with php

I have a php page where it loads some predefined options and text boxes with html codes.
Later it posts data on a remote page.

<img src="data:<?php echo $captchaQuery['content_type'] ?>;base64,<?php echo $captcha ?>" alt="Captcha" height="30" align="absbottom" id="msg_captcha" name="msg_captcha">
<input type="text" name="f_captcha" size="8" maxlength="5">
<input type="submit" value="SEND" class="btnorange">

Everything works fine most of the time including remote captcha verification. When I press send button the page submits to remote url and reloads the php page.

My question is, 'when user puts wrong data in the text box the remote site redirects to another page, how can i also grab that redirected link and redirect user to that page rather than reloading my php?

Target url for for submitting data is : $baseurl . ?psean=.

if there is an error ridirects to : $baseurl . ?psean= captcha was wrong

See if the server sends redirect location in response headers

$url = "http://www.google.com";
$headers = get_headers($url, 1);
if(!empty($headers['Location']))
  header('Location:' . current($headers['Location']));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM