Jump to content

If URL then script


Mucker
Go to solution Solved by ginerjm,

Recommended Posts

The first block of code is what i want to use since i know it works, but i dont know how to use it with the code already there.

<?php

 if
 (strpos($_SERVER['REQUEST_URI'], 'upload.php') == false) {
echo 'the stuff below is removed, or if the URL is something else, its not removed'
?>

This code is already in my form and can not be changed!!! This is what I want to remove totally if the URL is upload.php

<div class="navbar" name"navbar" Id="navbar">
    <div class="navbar-inner" name="navbar-inner" Id="navbar-inner">'     
      <?php  echo  a_view('core/account/login_dropdown'); ?>
      <?php  echo  a_view_menu('topbar', array('sort_by' => 'priority', array('menu-hz'))); ?>
       <?php echo  a_view('search/search_box', array('class' => 'search-header')); ?>
    </div>
</div>

Can anyone help?

Link to comment
Share on other sites

Have no idea what you are trying to do, but try this.

 

 

<?php  

if  (strpos($_SERVER['REQUEST_URI'], 'upload.php') == false)

{

   echo 'the stuff below is removed, or if the URL is something else, its not removed'

}

else

{

   echo '<div class="navbar" name"navbar" Id="navbar">';    

   echo '<div class="navbar-inner" name="navbar-inner" Id="navbar-inner">';          

   echo  a_view('core/account/login_dropdown');

   echo  a_view_menu('topbar', array('sort_by' => 'priority', array('menu-hz') ) );

   echo  a_view('search/search_box', array('class' => 'search-header'));

   echo '</div> </div>';

}

 

This would prevent the second part from being output.

 

Note - there is at least one error in that code, so I don't think it's working as shown.  Also your first if statement is backwards if you want the "else" stuff dropped if the uri is upload.php

Link to comment
Share on other sites

Have no idea what you are trying to do, but try this.

 

 

<?php  

if  (strpos($_SERVER['REQUEST_URI'], 'upload.php') == false)

{

   echo 'the stuff below is removed, or if the URL is something else, its not removed'

}

else

{

   echo '<div class="navbar" name"navbar" Id="navbar">';    

   echo '<div class="navbar-inner" name="navbar-inner" Id="navbar-inner">';          

   echo  a_view('core/account/login_dropdown');

   echo  a_view_menu('topbar', array('sort_by' => 'priority', array('menu-hz') ) );

   echo  a_view('search/search_box', array('class' => 'search-header'));

   echo '</div> </div>';

}

 

This would prevent the second part from being output.

 

Note - there is at least one error in that code, so I don't think it's working as shown.  Also your first if statement is backwards if you want the "else" stuff dropped if the uri is upload.php

Can you define how it's backwards? I am working on a website with a friend, and we are just stuck on this bit. If you could fix the code, I would be most greatful

Link to comment
Share on other sites

I can't edit my post so i am bumping it to explain what i need. Basically ginerjm from the second block of code. Thats from another php script, but i need to exclude that php script becuase I don't want it visible on the page i am working on, but I need it visible on other pages.

Link to comment
Share on other sites

  • Solution

And that's what I deduced.

 

As for your error.

 

Your original post:

<?php  

if  (strpos($_SERVER['REQUEST_URI'], 'upload.php') == false)

{

   echo 'the stuff below is removed, or if the URL is something else, its not removed'

?>

 

is flawed.  You are missing the closing curly bracket as well as a semi at the end of the echo.  So obviously you've never run this code.

 

Anyway this statement says "if the uri does NOT contain 'upload.php' show the message 'stuff is removed'.   You were close - you just have to include the code that you wanted to remove.  So - taking my post and correcting it you would have:

 

<?php  

if  (strpos($_SERVER['REQUEST_URI'], 'upload.php') == false)

{

   echo '<div class="navbar" name"navbar" Id="navbar">';     // this line has an error

   echo '<div class="navbar-inner" name="navbar-inner" Id="navbar-inner">';          

   echo  a_view('core/account/login_dropdown');   // I'm assuming that "a_view" is some function defined somewhere

   echo  a_view_menu('topbar', array('sort_by' => 'priority', array('menu-hz') ) );   // again - a function call?

   echo  a_view('search/search_box', array('class' => 'search-header'));

   echo '</div> </div>';

}

 

Now the code will NOT be displayed if the uri contains your script name.

Edited by ginerjm
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.