0

is there a way to use real link in include? bc the code below doesnt work. it say cant use http.

  login.php
    <?php
          include("http://localhost/E_COMMERCE/INCLUDE/header.php");
    ...
    ?>
    ---------------------------------------------------------------------

    header.php
    ...
    <link rel='stylesheet' type='text/css' href='css/main.css' />
    ...
-------------------------------------------------------------------------------

another way in login.php, i can do this code below. but the problem is that css file doesnt get linked in login.php

include("../INCLUDE/header.php");

my folder set up or tree

>wampp
   >htdocs
        >E_COMMERCE
               >CSS
                    >main.css
               >INCLUDE
                    >HEADER.php
               >LOGIN
                    >login.php

another question is that which is better
../INCLUDE/header.php
vs
http://localhost/E_COMMERCE/INCLUDE/header.php
vs
E_COMMERCE/INCLUDE/header.php
i guess problem with 2nd link will be when you want to put your website online. than you will have to change your links bc it wont be localhost any more.

Edited by hwoarang69

2
Contributors
4
Replies
5
Views
4 Years
Discussion Span
Last Post by hwoarang69
Featured Replies
  • As far as I'm aware, it is possible to include files from another server. There is a common security setting PHP sets to avoid this called `allow_url_fopen` which has to be changed. It is not good practice to do so though, because urls can change. The following is the best … Read More

1

As far as I'm aware, it is possible to include files from another server. There is a common security setting PHP sets to avoid this called allow_url_fopen which has to be changed. It is not good practice to do so though, because urls can change. The following is the best practice to implement:

<?php include('../INCLUDE/header.php'); ?>

As for your CSS file not being loaded in, that's because it's looking for it in the same directory as the login.php file. You'll have to set the href to '../CSS/main.css'

0

thanks,

this is my log out scrip but not seem to get me log off. on echo it prints username so that means setcookie to null is not working.
logout.php

<?php
include('../INCLUDE/connect.php');

setcookie("id", "", time()-172800);
setcookie("username", "", time()-172800);

$c =$_COOKIE['username'];
echo"$c";
?>

the problem might be in my path bc i was changing it.

>css
     main.css
>image
>include
      connect.php
      header.php
>login_pages
      logout.php
      login.php
>index.php

Edited by hwoarang69

0

i kind of see the problem now.
i am setin up cookie in my login.php page.

<?php
session_start(); //for errors
....

setcookie("id", $id, time()+172800); 
setcookie("username", $username_p, time()+172800); //seconds - 2 days 
header("location: ../index.php");
...
$_SESSION['log_error'] = $log_error;
?>

for some reason cookie doesnt get safe when it goes to index.php.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.