Jump to content

How can i set a default variable if one has not been set in the url?


Jarid

Recommended Posts

I am using this php code <?php echo $_GET['CiFrame']; ?> to check the url for the variable CiFrame, this allows me to link to a page through my page containing the iframe.

 

Here is my iframe code.

<iframe name="CiFrame" width="727" height="805" src="<?php echo $_GET['CiFrame']; ?>" scrolling="auto" frameborder="0"></iframe>

 

The problem is that if the url does not contain a variable the iframe will not open a page. How can i set a default variable if one is not provided?

 

Thank You

Link to comment
Share on other sites

I don't understand how to apply the code you provided. I set $Openme as the var. I still don't understand how to check the url for CiFrame or use a default value if CiFrame is not specified in the url. Here is what i tried next, however it did not work. Any ideas?

 

<?php

if (isset ($_GET['CiFrame']))

  $Openme = 'CiFrame';

else

$Openme = '/NonMembersFeatured.php';

?>

 

Iframe Code

<iframe name="CiFrame" width="727" height="805" src="<?php $Openme ?>" scrolling="auto" frameborder="0"></iframe>

 

Thank You

Link to comment
Share on other sites

I don't understand how to apply the code you provided. I set $Openme as the var. I still don't understand how to check the url for CiFrame or use a default value if CiFrame is not specified in the url. Here is what i tried next, however it did not work. Any ideas?

 

<?php

if (isset ($_GET['CiFrame']))

  $Openme = 'CiFrame';

else

$Openme = '/NonMembersFeatured.php';

?>

 

Iframe Code

<iframe name="CiFrame" width="727" height="805" src="<?php $Openme ?>" scrolling="auto" frameborder="0"></iframe>

 

Thank You

 

that should be:

<?php
if (isset ($_GET['CiFrame']))
  $Openme = $_GET['CiFrame'];
else
$Openme = '/NonMembersFeatured.php';
?>

 

Link to comment
Share on other sites

I put

<?php
if (isset ($_GET['CiFrame']))
  $Openme = $_GET['CiFrame'];
else
$Openme = '/NonMembersFeatured.php';
?>

In the body right above my iframe code

<iframe name="CiFrame" width="727" height="805" src="<?php $Openme ?>" scrolling="auto" frameborder="0"></iframe>

 

I uploaded the page to my server and opened it in my browser. The iframe did not open /NonMembersFeatured.php and when i right clicked and went to source code my iframe showed src="". Why is this not working?

 

 

Link to comment
Share on other sites

I put

<?php
if (isset ($_GET['CiFrame']))
  $Openme = $_GET['CiFrame'];
else
$Openme = '/NonMembersFeatured.php';
?>

In the body right above my iframe code

<iframe name="CiFrame" width="727" height="805" src="<?php $Openme ?>" scrolling="auto" frameborder="0"></iframe>

 

I uploaded the page to my server and opened it in my browser. The iframe did not open /NonMembersFeatured.php and when i right clicked and went to source code my iframe showed src="". Why is this not working?

 

Try:

 

<iframe name="CiFrame" width="727" height="805" src="<?php echo isset ($_GET['CiFrame'])?$_GET['CiFrame']:'/NonMembersFeatured.php' ?>" scrolling="auto" frameborder="0"></iframe>

 

do tell if that worked

Link to comment
Share on other sites

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.