Graxeon Posted December 27, 2008 Share Posted December 27, 2008 I have this: <?php $allowed_url = array("google.com","http://yahoo.com"); //get the url from the url - lol $passed_url = $_GET['url']; //this would be http://www.google.com foreach ($allowed_url as $allowed) { if(stristr($allowed, $passed_url) !== false) { header("Location: ".str_replace("url=", "", $_SERVER['QUERY_STRING'])."/search?hl=en&q=php"); exit; } } header("Location: ".str_replace("url=", "", $_SERVER['QUERY_STRING'])."Denied"); ?> I want to have the option of adding text at the beginning of the input, not just the end. So...how can I do this: -User calls file.php?url=google.com -file.php does this: video.[inputhere]/videorankings?type=blogged&cr=usa&hl=en -Then file.php redirects the user to the new URL (which would be: http://video.google.com/videorankings?type=blogged&cr=usa&hl=en) Also, can you show me how to just have a beginning addition? Example: file.php redirects the user to: http://video.google.com instead of adding the backend "/videorankings?type=blogged&cr=usa&hl=en" to it Edit: Oh...sorry 1 last question: Instead of redirecting a user to "input+Denied" how can I redirect a user to "http://www.google.com/" ? Link to comment https://forums.phpfreaks.com/topic/138589-solved-newtext-input-here-newtext2/ Share on other sites More sharing options...
Graxeon Posted December 28, 2008 Author Share Posted December 28, 2008 Anyone? I really help with this Link to comment https://forums.phpfreaks.com/topic/138589-solved-newtext-input-here-newtext2/#findComment-724733 Share on other sites More sharing options...
MadTechie Posted December 28, 2008 Share Posted December 28, 2008 file.php?url=google.com <?php $URL = $_GET['url']; $allowed_url = array("google.com","http://yahoo.com"); if(in_array($URL,$allowed_url)) { header("http://video.".$URL."/videorankings?type=blogged&cr=usa&hl=en"); }else{ header("http://www.google.com/"); } ?> Link to comment https://forums.phpfreaks.com/topic/138589-solved-newtext-input-here-newtext2/#findComment-724736 Share on other sites More sharing options...
Graxeon Posted December 28, 2008 Author Share Posted December 28, 2008 It doesn't work Here's the test page: http://fr33.ulmb.com/gr/grpl2.php?url=google.com Link to comment https://forums.phpfreaks.com/topic/138589-solved-newtext-input-here-newtext2/#findComment-724856 Share on other sites More sharing options...
MadTechie Posted December 28, 2008 Share Posted December 28, 2008 Opps missed "Location: " try this <?php $URL = $_GET['url']; $allowed_url = array("google.com","yahoo.com"); if(in_array($URL,$allowed_url)) { header("Location: http://video.".$URL."/videorankings?type=blogged&cr=usa&hl=en"); }else{ header("Location: http://www.google.com/"); } ?> Link to comment https://forums.phpfreaks.com/topic/138589-solved-newtext-input-here-newtext2/#findComment-724860 Share on other sites More sharing options...
Graxeon Posted December 28, 2008 Author Share Posted December 28, 2008 I'm an idiot...I fixed it (almost), lol: <?php $URL = $_GET['url']; $allowed_url = array("google.com","http://yahoo.com"); if(in_array($URL,$allowed_url)) { header("Location: ".str_replace("url=", "http://video.", $_SERVER['QUERY_STRING'])."/videorankings?type=blogged&cr=usa&hl=en"); }else{ header("http://www.google.com/"); } ?> The redirect to "http://www.google.com/" doesn't work when an input isn't part of the array, can someone help me with that, please? Link to comment https://forums.phpfreaks.com/topic/138589-solved-newtext-input-here-newtext2/#findComment-724863 Share on other sites More sharing options...
Graxeon Posted December 28, 2008 Author Share Posted December 28, 2008 Ok fine, MadTechie's is better D: Link to comment https://forums.phpfreaks.com/topic/138589-solved-newtext-input-here-newtext2/#findComment-724866 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.