1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Php code appearing after login button

Discussion in 'Web Design & Development' started by cudsuk, Jan 5, 2013.

Thread Status:
Not open for further replies.
Advertisement
  1. cudsuk

    cudsuk Thread Starter

    Joined:
    Jan 5, 2013
    Messages:
    1
    Hi everyone i need some help with some php code as i get code after my login button

    (Attached image )

    I have narrowed it down to my template.php

    Code:
    <? }
    					else
    					  { 
    						echo '<p align="center" style="font-weight:bold;color:white;"><span>Welcome '.$_SESSION['LOgIn'].'</span></p>';
    						echo '<p>&nbsp;&nbsp;<a href="'.$siteurl.'/profile.php?show_favorites='.$_SESSION['LOgIn'].'"  class="lilogin"> visit your profile</a><br>';
    						echo '&nbsp;&nbsp;<a href="'.$siteurl.'/logout.php"  class="lilogin"> log out</a></p>';
    					  }	
    					?>
    Can anyone shed some light on it for me please , cheers
     

    Attached Files:

  2. gurutech

    gurutech

    Joined:
    Apr 23, 2004
    Messages:
    2,960
    I believe you need "<?php" at the beginning of your code...
     
  3. JiminSA

    JiminSA

    Joined:
    Dec 15, 2011
    Messages:
    3,332
    First Name:
    Jim
    Hoping to catch the eye of one of our moderators... When clicking on the attachment in this thread start posting, the image downloaded as opposed to opening in another tab as per usual:confused:
     
  4. peonowns

    peonowns

    Joined:
    Apr 16, 2012
    Messages:
    165
    PHP Syntax Check: Parse error: syntax error, unexpected '}' in your code on line 1
    Error: There is 1 more closing curly braces '}' than expected

    also i i dont think u need tht else ?.

    try this.

    <?

    {
    echo '<p align="center" style="font-weight:bold;color:white;"><span>Welcome '.$_SESSION['LOgIn'].'</span></p>';
    echo '<p>&nbsp;&nbsp;<a href="'.$siteurl.'/profile.php?show_favorites='.$_SESSION['LOgIn'].'" class="lilogin"> visit your profile</a><br>';
    echo '&nbsp;&nbsp;<a href="'.$siteurl.'/logout.php" class="lilogin"> log out</a></p>';
    }
    ?>
     
  5. SoftMaster

    SoftMaster

    Joined:
    Jan 20, 2013
    Messages:
    23
    Hi all,

    cudsuk, you must avoid to "echo" the HTML code, the elegant and correct way is only echoing the variables:
    PHP:
                        <?php 
                        
    }
                        else
                          { 
                          
    ?>
                            <p align="center" style="font-weight:bold;color:white;"><span>Welcome <?php echo $_SESSION['LOgIn'];?></span></p>
                            <p>&nbsp;&nbsp;<a href="<?php echo $siteurl;?>/profile.php?show_favorites=<?php echo $_SESSION['LOgIn'];?>"  class="lilogin"> visit your profile</a><br>
                            &nbsp;&nbsp;<a href="<?php echo $siteurl;?>/logout.php"  class="lilogin"> log out</a></p>
                         <?php                        
                          
    }    
                        
    ?>
    I didn't test this piece of code, but you can take an idea of what I mean.

    Also I recommend you a good code editor like Geany

    Thanks for reading.
     
  6. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1083920

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice