Jump to content

Recommended Posts

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

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/");
}
?>

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/");
}
?>

 

 

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?

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.