Jump to content

[SOLVED] If input = ____, then...


Graxeon

Recommended Posts

I have this script:

 

<?php
$allowed_url = array("umm",
"uhh",
"blankspothere");

$passed_url = $_GET['url']; 

foreach ($allowed_url as $allowed) {
    if(stristr($allowed, $passed_url) !== false) {

header("Location: http://www.google.com/search?=" .$allowed);
             exit;
   }
}


?>

 

However, instead of calling the script with something like "script.php?url=uhh"...I want to call the script with something like "script.php?url=car1"

 

What's the difference? Well...in the script I want the input "car1" to be equal to the input "uhh".

 

So instead of the script linking to "http://www.google.com/search?=uhh" directly from the input...I want the "uhh" to be hidden from the user's eyes and just be running in the background.

 

 

I hope that makes sense xD

Link to comment
https://forums.phpfreaks.com/topic/146608-solved-if-input-____-then/
Share on other sites

@sam: I can't use either with my host.

 

@thorpe (and everyone else) :

 

Ok...say I want to call "umm". To do that, I use: "script.php?url=umm"

 

BUT...I don't to see that it is titled "umm" in the input. SO...in "script.php" I have a little "converter/translator". Let's say that "umm = car1". Now I can call "umm" by using "script.php?url=car1".

 

Now do you understand? :P

 

So it's kind of like saying:

 

if input of "script.php?url=" = car1

Then check to see what car1 is equal to in the "converter"

 

This is the converter:

 

car1 = umm

 

Now that we have "umm"...we want to use that for the rest of the script. In this case, it is to link to some search on google.com

 

 

Ok...if that makes sense...then please show me how I can do this. My next question (once that is answered) is how to implement it into this script:

 

<?php
$allowed_url = array("umm",
"uhh",
"blankspothere");

$passed_url = $_GET['url']; 

foreach ($allowed_url as $allowed) {
    if(stristr($allowed, $passed_url) !== false) {

header("Location: http://www.google.com/search?=" .$allowed);
             exit;
   }
}


?>

 

I want to make it so after the input is converted...I want to run this part of the script:

 

header("Location: http://www.google.com/search?=" .$allowed);

 

If the conversion was unsuccessful (meaning that ex. "car55" doesn't exist in the script) then I just want the script to link the person to google's homepage.

 

 

(So normally, as seen in my script, I would have to run it through a "checker" to see if the input is allowed. However...now I just want to make it to check to see if it is in the conversion combos list.)

Either way the client is going to see what is passed along in the querystring to google, but this achives what I believe you are attempting.

 

<?php

if (isset($_GET['url'])) {

  $converter = array('car1' => 'umm');
  $url = $_GET['url']; 

  if (isset($converter[$url])) {
    header("Location: http://www.google.com/search?=" . $converter[$url]);
    exit;
  }
}

?>

 

Called like script.php?url=car1 this script would redirect to http://www.google.com/search?=umm

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.