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

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

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';
?>

 

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?

 

 

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

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.