Jump to content

isset and switch case


swampone

Recommended Posts

i have a form that is a search field. When submitted it goes through a switch case statement. And if certain search words are entered a url for that case should be returned, but instead its using the default case url for every word entered in the search field. For example if a user enters amateur in the search field it goes to the default case. I know that the $searchTerm is making it through all the cases, because if you look at the default case it has $searchTerm in the url, and once form is submitted I can see the searchTerm in the url and the script is working properly. But it seems like its not stopping once it has a match with one of the cases.

if (isset($_GET['search'])){
	$searchTerm = isset($_GET['search']);
	switch ($searhTerm){

	case "":
		$url = "http://www.pornhub.com/video?o=mr&page=$page";
		break;
	case "amateur":
		$url = "http://www.pornhub.com/video?c=3&page=$page";
		break;
	case "anal":
		$url = "http://www.pornhub.com/video?c=35&page=$page";
		break;
               default:
		$url = "http://www.pornhub.com/video/search?search=$searchTerm&x=0&y=0&page=$page";
		break;
		}
}


Link to comment
https://forums.phpfreaks.com/topic/206637-isset-and-switch-case/
Share on other sites

Wow!! That worked. You saved me so much time. I probably would been at it for hours trying to figure this out. After your explaination, I see what you are saying about anything entered returned true, but how you came up with

? $_GET['search'] : ''

Wow! I still have a lot to learn. Thanks a bunch.

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.