Jump to content

[SOLVED] help with url?venue=location, assigning venue value to a variable.


Recommended Posts

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.

 

 

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.

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?

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.

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.