idix
idix

Reputation: 443

PHP links are not working

I just got started with PHP to build my website. Everything was fine, untile I tried to use my navbar. This is what it looks like:

This is navbar.php which gets included into index.php.

<div class="nav-items">
    <ul>
        <li><a href="biography.php">Biography</a></li>
        <li><a href="music.php">Music</a></li>
        <li><a href="pictures.php">Pictures</a></li>
        <li><a href="concerts.php">Concerts</a></li>
        <li><a href="booking.php">Booking</a></li>
    </ul>
</div>

When I click a link in my navbar, it doesn't direct me to the page. It's the same behavior as when you'd write href="#". I just stay on the page, the URL doesn't change.

When I hover over the links, the path I see is correct. And when I manually type in that path, it works perfectly, the page gets rendered.

My file structure:

I'm using XAMPP to run the site locally. Can anyone see what I'm doing wrong here?

EDIT:

Thanks to @syck I've now found out that a part of my jQuery code was responsible. It was code I used to display the active page:

$(function() {
    $('.navbar').on('click', 'div.nav-items ul li a', function(e) {
        e.preventDefault();
        $(this).parents('.navbar').find('.active').removeClass('active').end().end().addClass('active');
        $(activeTab).show();
    });
});

Once this code is removed, navigation works like a charm. Anyone know why it would cause this behavior?

Upvotes: 2

Views: 9220

Answers (4)

Prog Sspl
Prog Sspl

Reputation: 9

i think there is some error with the path u have given.. give the correct path. check whether biography.php is found in the same location where the index.php is found.

Upvotes: 0

Add

<base href="your website" > 
element in index.php

Upvotes: 0

Anish Rai
Anish Rai

Reputation: 686

  <div class="nav-items">
  <ul>
     <li><a href="../biography.php">Biography</a></li>
     <li><a href="../music.php">Music</a></li>
     <li><a href="../pictures.php">Pictures</a></li>
     <li><a href="../concerts.php">Concerts</a></li>
     <li><a href="../booking.php">Booking</a></li>
  </ul>
</div>

i hope this will work

Upvotes: 2

Lalji Tadhani
Lalji Tadhani

Reputation: 14169

Try this way

<div class="nav-items">
    <ul>
        <li><a href="../biography.php">Biography</a></li>
        <li><a href="../music.php">Music</a></li>
        <li><a href="../pictures.php">Pictures</a></li>
        <li><a href="../concerts.php">Concerts</a></li>
        <li><a href="../booking.php">Booking</a></li>
    </ul>
</div>

Upvotes: 0

Related Questions