Graxeon Posted February 24, 2009 Share Posted February 24, 2009 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 More sharing options...
trq Posted February 24, 2009 Share Posted February 24, 2009 I hope that makes sense Nope, not at all. Link to comment https://forums.phpfreaks.com/topic/146608-solved-if-input-____-then/#findComment-769657 Share on other sites More sharing options...
samshel Posted February 24, 2009 Share Posted February 24, 2009 try url rewriting and .htaccess, google for it Link to comment https://forums.phpfreaks.com/topic/146608-solved-if-input-____-then/#findComment-769664 Share on other sites More sharing options...
Graxeon Posted February 24, 2009 Author Share Posted February 24, 2009 @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? 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.) Link to comment https://forums.phpfreaks.com/topic/146608-solved-if-input-____-then/#findComment-769677 Share on other sites More sharing options...
samshel Posted February 24, 2009 Share Posted February 24, 2009 store the mapping in database, for what_you_want_to_show vs what_you_want_to_use, while displaying links use what_you_want_to_show, while doing operations, find corresponding what_you_want_to_use and use it.. Link to comment https://forums.phpfreaks.com/topic/146608-solved-if-input-____-then/#findComment-769679 Share on other sites More sharing options...
Graxeon Posted February 24, 2009 Author Share Posted February 24, 2009 I don't have mySQL either xD. That's why I need it in the script itself Link to comment https://forums.phpfreaks.com/topic/146608-solved-if-input-____-then/#findComment-769686 Share on other sites More sharing options...
corbin Posted February 24, 2009 Share Posted February 24, 2009 An array would work just fine.... Or even a flat file loaded into an array (I would just hard code it personally, unless you plan on making a script to change it). Link to comment https://forums.phpfreaks.com/topic/146608-solved-if-input-____-then/#findComment-769697 Share on other sites More sharing options...
Graxeon Posted February 24, 2009 Author Share Posted February 24, 2009 Can you show me how to do it with an array? Link to comment https://forums.phpfreaks.com/topic/146608-solved-if-input-____-then/#findComment-769743 Share on other sites More sharing options...
trq Posted February 24, 2009 Share Posted February 24, 2009 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 Link to comment https://forums.phpfreaks.com/topic/146608-solved-if-input-____-then/#findComment-769794 Share on other sites More sharing options...
Graxeon Posted February 25, 2009 Author Share Posted February 25, 2009 It works, thank you! Link to comment https://forums.phpfreaks.com/topic/146608-solved-if-input-____-then/#findComment-770693 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.