Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New Coder
    Join Date
    Mar 2010
    Posts
    58
    Thanks
    10
    Thanked 3 Times in 3 Posts

    PHP breaking CSS format

    This is driving me crazy!!!!

    I have this bit of PHP code that's breaking my CSS layout.

    Code:
    <?php
    if ($user->data['is_registered']) { ?>
    <div id="user_menu">
    <a href="<?php echo $forum; ?>/ucp.php?mode=logout&amp;sid=<?php echo  $user->data['session_id'] ?>">Logout</a><br>
    <a href="<?php echo $forum; ?>/search.php?search_id=newposts">View new Posts</a><br>
    <a href="<?php echo $forum; ?>/ucp.php?i=pm&folder=inbox">View new PM\'s</a><br>
    <a href="<?php echo $forum; ?>/ucp.php">User CP</a><br>
    <a href="<?php echo $forum; ?>/ucp.php?i=profile&amp;mode=signature">Edit Signature</a><br>
    <a href="<?php echo $forum; ?>/search.php?search_id=egosearch">My Posts</a><br />
    </div>
    <?php } else { ?>
    	
    <form method="post" action="<?php $root.$login_page ?>" name="Username" target="_self" >
    <div id="login_title" >
    Forum login
    </div>
    <div id="username_lable">
    Username
    </div>
    <div id="usename_textbox">
    <input class="forminput" value=" User Name" onfocus="this.value=''" id="username" name="username" size="16" /> 
    </div>
    <div id="password_lable">
    Password
    </div>
    <div id="password_textbox">
    <input class="forminput" value="password" type="password" onfocus="this.value=''" id="password" name="password" size="16"/> 
    </div>
    <div id="form_submit">
    <input class="forminput" type="image" src="../../images/login_submit_btn.jpg" value="Log in" name="login" />
    </div>
    </form>
    <a href="http://127.0.0.1/forum/ucp.php?mode=register"><img src="../../forum/styles/prosilver/theme/images/icon_register.gif" width="16" height="14" />Register</a>
    </div>
    <div id="forgot_pass_link">
    <a id="login_box_open"  href="http://127.0.0.1/forum/ucp.php?mode=sendpassword">Forgot Your Password?</a>
    </div>
    <?php } ?>
    I don't think it's the CSS because the else statement works fine with my css. It's the if statement that breaks it. It seems that the php if floating outside of the wrapper div, but I can't figure out how to correct this.

  • #2
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,314
    Thanks
    4
    Thanked 207 Times in 204 Posts
    What exactly is it breaking? Can you provide a link to what it should like or an image?
    Dave .... HostMonster for all of your hosting needs

  • #3
    Regular Coder poyzn's Avatar
    Join Date
    Nov 2010
    Posts
    266
    Thanks
    2
    Thanked 61 Times in 61 Posts
    where is the opening div tag for the bolded closing div tag?
    <a href="http://127.0.0.1/forum/ucp.php?mode=register"><img src="../../forum/styles/prosilver/theme/images/icon_register.gif" width="16" height="14" />Register</a>
    </div>

  • #4
    Senior Coder
    Join Date
    Sep 2010
    Posts
    2,451
    Thanks
    17
    Thanked 275 Times in 275 Posts
    Don't do this:
    PHP Code:
    <?php
    if ($user->data['is_registered']) { ?>
    <div id="user_menu">
    <a href="<?php echo $forum?>/ucp.php?mode=logout&amp;sid=<?php echo  $user->data['session_id'?>">Logout</a><br>
    <a href="<?php echo $forum?>/search.php?search_id=newposts">View new Posts</a><br>
    <a href="<?php echo $forum?>/ucp.php?i=pm&folder=inbox">View new PM\'s</a><br>
    <a href="<?php echo $forum?>/ucp.php">User CP</a><br>
    <a href="<?php echo $forum?>/ucp.php?i=profile&amp;mode=signature">Edit Signature</a><br>
    <a href="<?php echo $forum?>/search.php?search_id=egosearch">My Posts</a><br />
    </div>
    <?php } else { ?>

    That's very bad coding. If need be echo every line that belongs in the HTML, but don't leave { or } hanging like that.

    echo '<a href="'.$forum.'/search.php?search_id=newposts">View new Posts</a><br>';
    You can probably echo the entire block and the one below it with proper escape language.

  • #5
    New Coder
    Join Date
    Mar 2010
    Posts
    58
    Thanks
    10
    Thanked 3 Times in 3 Posts
    <a href="http://127.0.0.1/forum/ucp.php?mode=register"><img src="../../forum/styles/prosilver/theme/images/icon_register.gif" width="16" height="14" />Register</a>
    </div>
    It's just a typo.

    Code:
    <div id="register_link">
    <a href="http://127.0.0.1/forum/ucp.php?mode=register"><img src="../../forum/styles/prosilver/theme/images/icon_register.gif" width="16" height="14" />Register</a>
    </div>
    That's very bad coding. If need be echo every line that belongs in the HTML, but don't leave { or } hanging like that.

    echo '<a href="'.$forum.'/search.php?search_id=newposts">View new Posts</a><br>';
    Yeah I know, I had it that way originally, I changed it to see if it would help. Didn't make a bit of difference.

  • #6
    New Coder
    Join Date
    Mar 2010
    Posts
    58
    Thanks
    10
    Thanked 3 Times in 3 Posts
    Quote Originally Posted by gilgimech View Post
    It's just a typo.

    Code:
    <div id="register_link">
    <a href="http://127.0.0.1/forum/ucp.php?mode=register"><img src="../../forum/styles/prosilver/theme/images/icon_register.gif" width="16" height="14" />Register</a>
    </div>
    Ah, I got it. One of my div wasn't closed. Pointing out that typo helped my find it.

    Thanks.

  • #7
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,108
    Thanks
    11
    Thanked 101 Times in 99 Posts
    That's very bad coding. If need be echo every line that belongs in the HTML, but don't leave { or } hanging like that.
    why is it bad coding ?
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #8
    Senior Coder
    Join Date
    Sep 2010
    Posts
    2,451
    Thanks
    17
    Thanked 275 Times in 275 Posts
    Quote Originally Posted by firepages View Post
    why is it bad coding ?
    Maybe it's not, but it looks like it might be too subject to mis-interpretation by the browser.

  • #9
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,108
    Thanks
    11
    Thanked 101 Times in 99 Posts
    The browser only sees the HTML output it does not care how it is created.
    I would not, these days, code like that either but the last thing I would do is echo() everything, not that I think that is `bad` either, its all subjective
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #10
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,108
    Thanks
    11
    Thanked 101 Times in 99 Posts
    The browser only sees the HTML output it does not care how it is created.
    I would not, these days, code like that either but the last thing I would do is echo() everything, not that I think that is `bad` either, its all subjective
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •