I have a problem with my links getting added a extra subdirectory found to it when that link doesnt even exist I have tried everything possible, such as ../ to specifying to exact folder location within the links

Here what are the correct links are:
http://localhost/xampp/website/newsletter.php
http://localhost/xampp/website/admin/login.php

When I click on the login link to goto "http://localhost/xampp/website/admin/login.php"
the links are wrong by adding /admin to newsletter.php and an extra /admin to login.php:
http://localhost/xampp/website/admin/newsletter.php
http://localhost/xampp/website/admin/admin/login.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php
  session_start();

  $connect = mysql_connect('localhost', 'root', '') or die(mysql_error()); 
  $db = mysql_select_db('blog', $connect); 
   
  $session_name = isset($_SESSION['user_id']) ? $_SESSION['user_id'] : 0; 
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Home - </title>
<link href="css/styles.css" rel="stylesheet" type="text/css" />
<link href="../css/styles.css" rel="stylesheet" type="text/css" />
</head>

<body>
  <table border="0" cellspacing="5" cellpadding="3" align="center" width="1024">
    <tr>
	  <td id="header" align="center" valign="top">
	    <h1>Header here</h1>
	  </td>
	</tr>
	
	<tr>
	  <td id="navigation" align="center">
        <ul>    
          <li><a href="http://www.#.com/home">Home</a></li> |  
          <li><a href="http://www.#.com/news">Newsletter</a></li> |
          <li><a href="http://www.#.com/deanscolumn">Deans Column</a></li> |
          <li><a href="http://www.#.com/photos">Photos</a></li> |
          <li><a href="http://www.#.com/jobs">Jobs</a></li> |
          <li><a href="http://www.#.com/interships">Interships</a></li> |
	      <li><a href="http://www.#.com/scholarships">scholarships</a></li> |
          <li><a href="http://www.#.com/aboutus">About Us</a></li> |
          <li><a href="http://www.#.com/contactus">Contact Us</a></li>
        <ul>
	  </td>
	</tr>
	
	<tr>
	  <td id="admin" align="center">
	    <?php
		if ($session_name) {
		  echo "<a href=\"newsletter.php\">Newsletter </a>\n";
		  echo "<a href=\"admin/add.user.php\">Add Admin </a>\n";
		  echo "<a href=\"admin/logout.php\">Logut </a><br>\n";
		} else {
		  echo "<a href=\"newsletter.php\">Newsletter </a>\n ";
		  echo "<a href=\"admin/login.php\">Login </a>\n";
		}  
	    ?>           
	  </td>
	</tr>
	
	<tr>
	  <td id="content">
Member Avatar for diafol

either use the full url or use an aboslute (/ at the beginning).

yea i tried full url as well and / that doesnt work as well

is this page outside of admin folder?

the only pages outside from the admin folder is newsletter.php, header, and footer.php

pages that are in the admin folder are index.php, login.php, and add.user.php

Member Avatar for diafol

SO you're saying that:

echo "<a href=\"/newsletter.php\">Newsletter </a>\n";
 echo "<a href=\"/admin/add.user.php\">Add Admin </a>\n";
 echo "<a href=\"/admin/logout.php\">Logut </a><br>\n";
} else {
 echo "<a href=\"/newsletter.php\">Newsletter </a>\n ";
 echo "<a href=\"/admin/login.php\">Login </a>\n";

AND

echo "<a href=\"http://www.#.com/newsletter.php\">Newsletter </a>\n";
 echo "<a href=\"http://www.#.com/admin/add.user.php\">Add Admin </a>\n";
 echo "<a href=\"http://www.#.com/admin/logout.php\">Logut </a><br>\n";
} else {
 echo "<a href=\"http://www.#.com/newsletter.php\">Newsletter </a>\n ";
 echo "<a href=\"http://www.#.com/admin/login.php\">Login </a>\n";

Don't work?

href=\"./admin/login.php\">Login </a>\n"; ??

yes that is correct and i have even tried almostbob way as well

thats definitely not going to work cause its a website address, i am using a local server

definitely www.#.com was just for example.

$siteurl = "http://localhost/xampp/website/";

if ($session_name) {
echo '<a href="'.$siteurl.'/newsletter.php">Newsletter </a>\n';
 echo '<a href="'.$siteurl.'/admin/add.user.php">Add Admin </a>\n';
 echo '<a href="'.$siteurl.'/admin/logout.php">Logut </a><br>\n';
} else {
 echo '<a href="'.$siteurl.'/newsletter.php">Newsletter </a>\n ';
 echo '<a href="'.$siteurl.'/admin/login.php">Login </a>\n';

Try above code.
and whenever you upload files to live don't forget to change $siteurl.

Member Avatar for diafol

Have you set up a virtual host in C:\xampp\apache\conf\extra\httpd-vhosts.conf and C:\Windows\System32\drivers\etc\hosts ?

perhaps dumb, but what is the root setting on the wamp install?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.