WiFiTech Posted September 28, 2007 Share Posted September 28, 2007 Thanks for taking a few moments to look at this post. I have learned a lot in a week, and I think I figured out the best way to do something, however, I am not getting my syntax even close to correct. If someone you could help me with the basic concept or point me in the right direction I would be grateful. I am using the following for a url syntax: https://www.mydomain.com/index.php?venue=location examples: http://www.mydomain.com/index.php?venue=marina http://www.mydomain.com/index.php?venue=hotel Question #1: How do I GET the venue value from the URL? Question #2 How do I assign it to a variable? Question #3 How do I get the correct php include to show based on the variable with the Venue Value? <?php if ($_GET['venue'] == "marina") { $_welcomeinclude = "marina.php"; ?> } elseif ($_GET['venue'] == "hotel") { $_welcomeinclude = "hotel.php"; ?> } else { $_welcomeinclude = "welcome.php"; ?> } include \"$_include\"; ?> also, I am not getting this to work when the include file is in another directory. And I am certain that I would be better off assigning the venue value to a variable for use in other instances. Quote Link to comment https://forums.phpfreaks.com/topic/71069-solved-help-with-urlvenuelocation-assigning-venue-value-to-a-variable/ Share on other sites More sharing options...
rarebit Posted September 28, 2007 Share Posted September 28, 2007 $v = "default_value"; if(isset($_GET['venue'])) { $v = $_GET['venue']; echo $v; } Quote Link to comment https://forums.phpfreaks.com/topic/71069-solved-help-with-urlvenuelocation-assigning-venue-value-to-a-variable/#findComment-357321 Share on other sites More sharing options...
pocobueno1388 Posted September 28, 2007 Share Posted September 28, 2007 Try this out <?php if (isset($_GET['venue'])){ $welcominclude = $_GET['venue']; } else { $welcomeinclude = 'welcome'; } include 'path/'.$welcomeinclude; ?> Quote Link to comment https://forums.phpfreaks.com/topic/71069-solved-help-with-urlvenuelocation-assigning-venue-value-to-a-variable/#findComment-357323 Share on other sites More sharing options...
WiFiTech Posted September 28, 2007 Author Share Posted September 28, 2007 First, thank you rarebit and pocobueano1388. Here is what I took from your input... assume https://www.mydomain.com/index.php?location=marina assume include pages are in https://www.mydomain.com/location/ directory. <?php $location = "welcome"; if(isset($_GET['venue'])) { $location = $_GET['venue']; echo $location; } ?> This should then set the variable $location to a default of welcome.php unless the $_GET can pull a value from the url. In this case venue value is marina and it will assign it to the variable $location, which will then print to screen marina <?php if (isset($_GET['venue'])){ $location = $_GET['venue']; } else { $location = 'welcome'; } include 'location/'.$location.php; ?> This should pull the value of venue marina, it will then assign the variable $location the value of marina. however this will fail to pull the include of marina.php as I have the syntax wrong. I need a hand with the syntax on building the file name $location.php please. Quote Link to comment https://forums.phpfreaks.com/topic/71069-solved-help-with-urlvenuelocation-assigning-venue-value-to-a-variable/#findComment-357469 Share on other sites More sharing options...
pocobueno1388 Posted September 28, 2007 Share Posted September 28, 2007 You were close xP <?php if (isset($_GET['venue'])){ $location = $_GET['venue']; } else { $location = 'welcome'; } include 'location/'.$location.'.php'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/71069-solved-help-with-urlvenuelocation-assigning-venue-value-to-a-variable/#findComment-357475 Share on other sites More sharing options...
WiFiTech Posted September 28, 2007 Author Share Posted September 28, 2007 Testing, Testing and dang I am getting close though... Thanks pocobueno1388 here is the test url for the page... https://online.impulseconnect.com/learnphp/index.php obviously you place whatever ?venue=blahblah that you want to test with in this case welcome and marina are being used. welcome is a picture of a hummingbird and marina is a picture of a blob. here is the code for the script we are working with. <?php if (isset($_GET['venue'])){ $location = $_GET['venue']; } else { $location = 'welcome'; } include 'https://online.impulseconnect.com/learnphp/'.$location.'.php'; ?> I am recieving the warning and it seems I have to get the URL path corrected from the PHP directory back to the website directory area. Warning: main() [function.main]: SSL operation failed with code 1. OpenSSL Error messages: error:140770FC:SSL routines:func(119):reason(252) in /home/jkc1211/public_html/learnphp/index.php on line 63 Warning: main() [function.main]: php_stream_sock_ssl_activate_with_method: SSL handshake/connection failed in /home/jkc1211/public_html/learnphp/index.php on line 63 Warning: main(https://online.impulseconnect.com/learnphp/welcome.php) [function.main]: failed to open stream: Unable to activate SSL mode in /home/jkc1211/public_html/learnphp/index.php on line 63 Warning: main() [function.main]: SSL operation failed with code 1. OpenSSL Error messages: error:140770FC:SSL routines:func(119):reason(252) in /home/jkc1211/public_html/learnphp/index.php on line 63 Warning: main() [function.main]: php_stream_sock_ssl_activate_with_method: SSL handshake/connection failed in /home/jkc1211/public_html/learnphp/index.php on line 63 Warning: main(https://online.impulseconnect.com/learnphp/welcome.php) [function.main]: failed to open stream: Unable to activate SSL mode in /home/jkc1211/public_html/learnphp/index.php on line 63 Warning: main() [function.include]: Failed opening 'https://online.impulseconnect.com/learnphp/welcome.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/jkc1211/public_html/learnphp/index.php on line 63 any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/71069-solved-help-with-urlvenuelocation-assigning-venue-value-to-a-variable/#findComment-357508 Share on other sites More sharing options...
BlueSkyIS Posted September 28, 2007 Share Posted September 28, 2007 you can include a file, but you can't include a URL. if you need to include the local file /learnphp/'.$location.'.php' i'd use this: include($_SERVER['DOCUMENT_ROOT']."/learnphp/$location.php"); Quote Link to comment https://forums.phpfreaks.com/topic/71069-solved-help-with-urlvenuelocation-assigning-venue-value-to-a-variable/#findComment-357512 Share on other sites More sharing options...
WiFiTech Posted September 28, 2007 Author Share Posted September 28, 2007 Thank you to effigy, pocobueno1388 and BlueSkyIS Here is the final code that I can start to expand my knowledge with: <?php if (isset($_GET['venue'])){ $location = $_GET['venue']; } else { $location = 'welcome'; } include($_SERVER['DOCUMENT_ROOT']."/learnphp/$location.php"); ?> I just need to get the rest of the else statements and then learn how to move backwards in the directories, to pull existing content, then I should be able to clean it all up... Thanks so much everyone, any more issues or questions will be in a new thread pertaining to that subject. Quote Link to comment https://forums.phpfreaks.com/topic/71069-solved-help-with-urlvenuelocation-assigning-venue-value-to-a-variable/#findComment-357519 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.