Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8816817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:42:20+00:00 2026-06-14T04:42:20+00:00

I need some help. I’ve got some php code which I want on every

  • 0

I need some help.

I’ve got some php code which I want on every page of my site. But if I want to edit something in it ill have to edit every section of code ,in that php code, on every page. Is there a way so I can only edit on file and it reflects on all of the others on the other pages.

Here is the php code:

<?php


if (!$_SESSION["valid_user"])
        {
        // User not logged in, redirect to login page
        echo '<gen id= mess>You need to login to use this!!!</gen>';    
        echo "<p><a href=\"login.php\">login</a></p>";
        }else{

// Member only content
// ...
// ...
// ...

// Display Member information
echo "<p>User ID: " . $_SESSION["valid_id"];
echo "<p>Username: " . $_SESSION["valid_user"];

// Display logout link
echo "<p><a href=\"logout.php\">Click here to logout!</a></p>";
}
?>

P.S: i was thinking that is may work (but it didnt):

include 'filename';

or

require 'filename';
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T04:42:21+00:00Added an answer on June 14, 2026 at 4:42 am

    You can use require_once or include_once functions depending on your requirements:

    require_once("filename.php")
    include_once("filename.php")
    

    These are likely to be most appropriate to what you want to do, because you only want a header once.

    However, if you wanted to include something more than once, you can use:

    require("filename.php")
    include("filename.php")
    

    This is not restricted to simply including parts of pages that you wish to include – You can also use these functions to include files that contain functions that you wish to make use of in other parts of your code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help about PHP GD. Here is my piece of code. header(Content-type:
Need some help with a Magento php script.... I want do write an if
Need some help from javascript gurus. I have one page where http://www.google.com/finance/converter is embedded
Need some help with crypto routines in Java. Given a PKCS#7 signature, I want
Need some help in creating function which can create folders recursively with giving path:
I need some help writing a MySQL trigger. what i want to do is
I need some help with my jQuery script. I have a page that refreshes
I need some help with the design of a query. I've got one table
Need some help: I want to only pull back the results for a specific
Need some help finishing up this program, everything works and runs like I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.