← PHP

O que se passa com o meu código php ?

Lida 7503 vezes

Offline

fantas 
Membro
Mensagens 303 Gostos 1
Feedback +1

Troféus totais: 25
Trófeus: (Ver todos)
Level 5 Tenth year Anniversary Nineth year Anniversary Eighth year Anniversary Super Combination Combination Topic Starter Poll Voter Level 4 Level 3

Boas, tenho erros nesta parte do código e não consigo saber o porque :/
precisava de ajuda!

O erro que aparece é :Notice: Undefined index: id in...

Código: [Seleccione]
<tr>
        <td>
                <table align=center>
                <tr align=center>
                        <td><a href="index.php">Ask</a> | </td>
                        <td><a href="search.php">Questions</a> | </td>
                        <?php if ($_SESSION['id'] == ""): ?>
                        <td><a href="login.php">Login</a> | </td>
                        <td><a href="register.php">Register</a></td>
                        <?php else: ?>
                        <td><a href="expdir.php">Expert Directory</a> | </td>
                        <td><a href="logout.php">Logout</a> </td>
                        <?php endif; ?>
                </tr>
                </table>
                <table align=center>
                <tr align=center>
                    <?php if ($_SESSION['id'] != ""): ?>
                        <td><a href="cpanel.php">My Control Panel</a> | </td>
                        <td><a href="search.php?id=<?php echo $_SESSION['id']; ?>
">My Questions</a> | </td>
                        <?php if ($_SESSION['type'] == 'expert'): ?>
                                <td><a href="feedback.php">Feedback</a> | </td>
                        <?php endif; ?>
                        <td><a href="pm_inbox.php">Private Messenger</a> | </td>
                        <td><a href="reports.php?action=Accepted">Reports</a> | </td>
                        <td><a href="contact.php?action=Accepted">Contact</a> </td>
                    <?php endif; ?>
                </tr>
                </table>
        </td>
</tr>
Offline

fhanity 
Membro
Mensagens 191 Gostos 5
Feedback +1

Troféus totais: 18
Trófeus: (Ver todos)
Apple User Apple User Super Combination Combination Topic Starter Level 3 Level 2 Level 1 100 Posts 50 Posts

olhando por alto diria que n tens a variavel id definida.
Offline

ricardosequeira 
Membro
Mensagens 5 Gostos 0
Troféus totais: 17
Trófeus: (Ver todos)
Windows User Super Combination Combination Topic Starter Level 3 Level 2 Level 1 First Post Signature Karma

antes de efectuares a comparação testa se a variável está definida: isset($_SESSION['id'])
Offline

fantas 
Membro
Mensagens 303 Gostos 1
Feedback +1

Troféus totais: 25
Trófeus: (Ver todos)
Level 5 Tenth year Anniversary Nineth year Anniversary Eighth year Anniversary Super Combination Combination Topic Starter Poll Voter Level 4 Level 3

Consegui, substitui por

 <?php if (isset($_SESSION['id']) && $_SESSION['id'] != ""): ?>