Hello,

I have just begun recoding my site and whenever i use PHP to put data on a page via an IF statement it overlaps any cells that are below it, and it also seems to be extending my left menu to the right.

The left menu works when logged in, but when not logged in it extends to the left. And throughout my site the tables overlap when an if statement is used.

My Website (on temp host lol)


And here is an extract of the code that runs the second menu on the left:

<TR><TD background="images/index_07.gif" width="120" height="16" class="titlecontent">
					&nbsp;&nbsp;&nbsp;&nbsp;Members</TD>
				</TR><TR><TD class="leftcontent">
				<?PHP 
					if($_SESSION['ID']) {
					echo "Hello ".$_SESSION['Username']."!!<BR>Welcome<p><A HREF=\"?p=logout&r=home\">Logout</A>";
					} else { 
					echo "
					<form name=\"login\" method=\"POST\" action=\"?p=login&a=1&r=".$p."\">
					User:<br>
					<input type=\"text\" name=\"User\" id=\"User\" size=\"12\" class=\"menuinput\"><br>
					Password:<Br>
					<input type=\"password\" name=\"Pass\" id=\"Pass\" size=\"12\" class=\"menuinput\"><br>
					<input type=\"Submit\" name=\"Submit\" value=\"Login\">
					</form>";
					}
		echo '</TD></TR><TR><TD>
					<IMG src="images/index_08.gif" width="120" height="16" alt=""></TD></TR>
			</TABLE> 
		</TD>'; ?>
		<TD width="10">
			<IMG src="images/spacer.gif" width="10" height="10" alt=""></TD>

Thanks

/Knad

What you describe sure sounds strange, and I wish I could see your site so I'd know what you are talking about, but the link you provided is not working.

You said it works when user is logged in--that the problem occurs when user is NOT logged in. So, let's point the finger at your FORM. Try doing this...this is a stab in the dark....

"<form style=\"margin:0px;padding:0px;\" name=\"login\" method=\"POST\" action=\"?p=login&a=1&r=".$p."\">"

Hello

Updated Link - works for me and shows overlapping on main page

I have tried the code you suggested, but it doesnt work :( any more help would be greatly appreciated as that is happening on all pages i make.

Thanks

/Knad

Attachments
<?php
session_start( );
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>Knad.co.uk</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="style.css" type="text/css" media="screen">
</HEAD>
<BODY bgcolor="#FFFFFF">
<?PHP 
$dbh=mysql_connect ("localhost", "USER", "PASS") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("DATABASE"); 
$p = $_GET['p'];
 ?>
<TABLE align="center" id="main" width="800" border="0" cellpadding="0" cellspacing="0">
	<TR>
		<TD width="800" height="10" colspan="7">
			<IMG src="images/spacer.gif" width="800" height="10" alt=""></TD>
	</TR>
	<TR>
		<TD width="10" height="120">
			<IMG src="images/spacer.gif" width="10" height="120" alt=""></TD>
		<TD colspan="5">
			<IMG src="images/index_03.jpg" width="780" height="120" alt=""></TD>
		<TD width="10" height="120">
			<IMG src="images/spacer.gif" width="10" height="120" alt=""></TD>
	</TR>
	<TR>
		<TD width="800" height="10" colspan="7">
			<IMG src="images/spacer.gif" width="800" height="10" alt=""></TD>
	</TR>
	<TR>
		<TD width="10">
			<IMG src="images/spacer.gif" width="10" height="10" alt=""></TD>
		<TD width="120">
			<TABLE id="leftmenu" width="120" border="0" cellpadding="0" cellspacing="0">
				<TR><TD background="images/index_07.gif" width="120" height="16" class="titlecontent">
					&nbsp;&nbsp;&nbsp;&nbsp;Menu</TD>
				</TR><TR><TD class="leftcontent">
					<A HREF="?p=home" class="menulink">Home</A>
				</TD></TR><TR><TD class="leftcontent">
					<A HREF="?p=signup" class="menulink">Signup</A>
				</TD></TR><TR><TD class="leftcontent">
					<A HREF="?p=board" class="menulink">Guestbook</A></A>
					<?PHP if($_SESSION['ID']) { ?>
				</TD></TR><TR><TD class="leftcontent">
					<A HREF="?p=category" class="menulink">Add Category</A>
					<?PHP } ?>
				</TD></TR><TR><TD>
					<IMG src="images/index_08.gif" width="120" height="16" alt=""></TD></TR>
					<TR><TD>&nbsp;</TD></TR>
					<TR><TD background="images/index_07.gif" width="120" height="16" class="titlecontent">
					&nbsp;&nbsp;&nbsp;&nbsp;Members</TD>
				</TR><TR><TD class="leftcontent">
				<?PHP 
					if($_SESSION['ID']) {
					echo "Hello ".$_SESSION['Username']."!!<BR>Welcome<p><A HREF=\"?p=logout&r=home\">Logout</A>";
					} else { 
					echo "
					<form style=\"margin:0px;padding:0px;\" name=\"login\" method=\"POST\" action=\"?p=login&a=1&r=".$p."\">
					User:<br>
					<input type=\"text\" name=\"User\" id=\"User\" size=\"12\" class=\"menuinput\"><br>
					Password:<Br>
					<input type=\"password\" name=\"Pass\" id=\"Pass\" size=\"12\" class=\"menuinput\"><br>
					<input type=\"Submit\" name=\"Submit\" value=\"Login\">
					</form>";
					} ?>
				</TD></TR><TR><TD>
					<IMG src="images/index_08.gif" width="120" height="16" alt=""></TD></TR>
			</TABLE>
		</TD>
		<TD width="10">
			<IMG src="images/spacer.gif" width="10" height="10" alt=""></TD>
		<TD width="520">
			<TABLE id="content" width="480" border="0" cellpadding="0" cellspacing="0">
				<TR><TD background="images/index_09.gif" width="520" height="16" class="titlecontent">
					&nbsp;&nbsp;&nbsp;&nbsp;Main</TD>
				</TR><TR><TD>
						<?php        			  
							if(!$p) {
								$p = "home";
							}
							if(file_exists("pages/".$p.".php")) {
								include("pages/".$p.".php");
							} else {
								include("errors/404.php");
							}
						?>
				</TD></TR><TR><TD>
					<IMG src="images/index_10.gif" width="520" height="16" alt=""></TD></TR>
			</TABLE>
		</TD>
		<TD width="10">
			<IMG src="images/spacer.gif" width="10" height="10" alt=""></TD>
		<TD width="120">
			<TABLE id="rightmenu" width="120" border="0" cellpadding="0" cellspacing="0">
				<TR><TD background="images/index_07.gif" width="120" height="16" class="titlecontent">
					&nbsp;&nbsp;&nbsp;&nbsp;Menu</TD>
				</TR><TR><TD class="rightcontent">
					Content
				</TD></TR><TR><TD class="rightcontent">
					Content
				</TD></TR><TR><TD>
					<IMG src="images/index_08.gif" width="120" height="16" alt=""></TD></TR>
			</TABLE>
		</TD>
		<TD width="10">
			<IMG src="images/spacer.gif" width="10" height="10" alt=""></TD>
</TABLE>
</BODY>
</HTML>

any help guys? this really bugging me...i found out its only when i use forms :(

Please build a page that is as simple as possible that displays this issue. Can you create a table with only 2 columns with a form in one that creates this problem? If so, post that code so I can look at it. As it is, I can't tell what you expect the page to look like.

Try it without any PHP -- just HTML. Does the problem still exist?

I usually do trial and error with something like that.
Why don't you view the source code of the sign in page before you log in
and view again after you log in. Compare the codes, you might find a slight difference. That might help, Hope that helps. I am not too good with php... :o

This article has been dead for over six months. Start a new discussion instead.