...

View Full Version : PHP breaking CSS format



gilgimech
11-22-2010, 06:13 PM
This is driving me crazy!!!!

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



<?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.

djm0219
11-22-2010, 06:26 PM
What exactly is it breaking? Can you provide a link to what it should like or an image?

poyzn
11-22-2010, 06:26 PM
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>

DrDOS
11-22-2010, 06:27 PM
Don't do this:
<?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.

gilgimech
11-22-2010, 06:45 PM
<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.



<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.

gilgimech
11-22-2010, 06:54 PM
It's just a typo.



<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.

firepages
11-23-2010, 02:00 PM
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 ?

DrDOS
11-23-2010, 03:27 PM
why is it bad coding ?Maybe it's not, but it looks like it might be too subject to mis-interpretation by the browser.

firepages
11-24-2010, 11:52 AM
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 :)

firepages
11-24-2010, 11:52 AM
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 :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum